Skip to content

Commit

Permalink
Derive Deserialize for enums used in remote-api-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles-Schleich committed Dec 10, 2024
1 parent fb2d2bc commit a92ddb1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
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
3 changes: 2 additions & 1 deletion commons/zenoh-protocol/src/zenoh/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
// ZettaScale Zenoh Team, <[email protected]>
//
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

0 comments on commit a92ddb1

Please sign in to comment.