Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive Deserialize for enums used in remote-api-plugin #1653

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions commons/zenoh-protocol/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use core::{
str::FromStr,
};

use serde::Serialize;
use serde::{Deserialize, Serialize};
pub use uhlc::{Timestamp, NTP64};
use zenoh_keyexpr::OwnedKeyExpr;
use zenoh_result::{bail, zerror};
Expand Down Expand Up @@ -454,7 +454,7 @@ impl TryFrom<u8> for Priority {
}
}

#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Hash, Serialize)]
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u8)]
pub enum Reliability {
BestEffort = 0,
Expand Down Expand Up @@ -560,7 +560,7 @@ impl Channel {
}

/// Congestion control strategy.
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Deserialize)]
#[repr(u8)]
pub enum CongestionControl {
#[default]
Expand Down
4 changes: 3 additions & 1 deletion commons/zenoh-protocol/src/network/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ pub struct Request {
pub mod ext {
use core::{num::NonZeroU32, time::Duration};

use serde::Deserialize;

use crate::{
common::{ZExtZ64, ZExtZBuf},
zextz64, zextzbuf,
Expand All @@ -91,7 +93,7 @@ pub mod ext {
// ```
// The `zenoh::queryable::Queryable`s that should be target of a `zenoh::Session::get()`.
#[repr(u8)]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Deserialize)]
pub enum QueryTarget {
/// Let Zenoh find the BestMatching queryable capabale of serving the query.
#[default]
Expand Down
4 changes: 3 additions & 1 deletion commons/zenoh-protocol/src/zenoh/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
//
use alloc::{string::String, vec::Vec};

use serde::Deserialize;

use crate::common::ZExtUnknown;

/// The kind of consolidation to apply to a query.
#[repr(u8)]
#[derive(Debug, Default, Clone, PartialEq, Eq, Copy)]
#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize)]
pub enum ConsolidationMode {
/// Apply automatic consolidation based on queryable's preferences
#[default]
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/api/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ impl Sink<Sample> for Publisher<'_> {
/// If QoS is enabled, Zenoh keeps one transmission queue per [`Priority`] P, where all messages in
/// the queue have [`Priority`] P. These queues are serviced in the order of their assigned
/// [`Priority`] (i.e. from [`Priority::RealTime`] to [`Priority::Background`]).
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Deserialize)]
#[repr(u8)]
pub enum Priority {
RealTime = 1,
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/api/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl QueryState {
}
/// The kind of accepted query replies.
#[zenoh_macros::unstable]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Deserialize)]
pub enum ReplyKeyExpr {
/// Accept replies whose key expressions may not match the query key expression.
Any,
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/api/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub type SourceSn = u32;

/// The locality of samples to be received by subscribers or targeted by publishers.
#[zenoh_macros::unstable]
#[derive(Clone, Copy, Debug, Default, Serialize, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
pub enum Locality {
SessionLocal,
Remote,
Expand Down
Loading