Skip to content

Commit

Permalink
unifinshed
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Mar 29, 2024
1 parent ffe7cc6 commit 0776580
Show file tree
Hide file tree
Showing 31 changed files with 85 additions and 48 deletions.
6 changes: 3 additions & 3 deletions zenoh/src/primitives.rs → zenoh/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ mod admin;
pub mod session;
#[macro_use]
pub mod encoding;
mod handlers;
pub mod handlers;
mod info;
pub mod key_expr;
#[cfg(feature = "unstable")]
mod liveliness;
pub mod payload;
mod publication;
mod query;
pub mod publication;
pub mod query;
pub mod queryable;
pub mod sample;
mod scouting;
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/primitives/admin.rs → zenoh/src/api/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>
//
use crate::primitives::{
use crate::api::{
encoding::Encoding,
key_expr::KeyExpr,
payload::Payload,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>
//
use crate::primitives::payload::Payload;
use crate::api::payload::Payload;
use phf::phf_map;
use std::{borrow::Cow, convert::Infallible, fmt, str::FromStr};
use zenoh_buffers::{ZBuf, ZSlice};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//

//! Callback handler trait.
use crate::primitives::session::API_DATA_RECEPTION_CHANNEL_SIZE;
use crate::api::session::API_DATA_RECEPTION_CHANNEL_SIZE;
use std::sync::{Arc, Mutex, Weak};
use zenoh_collections::RingBuffer as RingBufferInner;
use zenoh_result::ZResult;
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/primitives/info.rs → zenoh/src/api/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//

//! Tools to access information about the current zenoh [`Session`](crate::Session).
use crate::primitives::session::SessionRef;
use crate::api::session::SessionRef;
use std::future::Ready;
use zenoh_core::{AsyncResolve, Resolvable, SyncResolve};
use zenoh_protocol::core::{WhatAmI, ZenohId};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
//! [`kedefine`] also allows you to define formats at compile time, allowing a more performant, but more importantly safer and more convenient use of said formats,
//! as the [`keformat`] and [`kewrite`] macros will be able to tell you if you're attempting to set fields of the format that do not exist.
use crate::net::primitives::Primitives;
use crate::primitives::{
use crate::api::{
selector::Selector,
session::{Session, Undeclarable},
};
use crate::net::primitives::Primitives;
use std::{
convert::{TryFrom, TryInto},
future::Ready,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! Liveliness primitives.
//!
//! see [`Liveliness`]
use crate::primitives::{
use crate::api::{
handlers::{locked, DefaultHandler, IntoHandler},
key_expr::KeyExpr,
query::{QueryConsolidation, QueryTarget, Reply},
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
//

//! Publishing primitives.
use crate::net::primitives::Primitives;
use crate::primitives::{
use crate::api::{
encoding::Encoding,
handlers::{locked, Callback, DefaultHandler, IntoHandler},
key_expr::{KeyExpr, KeyExprInner},
Expand All @@ -27,6 +26,7 @@ use crate::primitives::{
value::Value,
Id,
};
use crate::net::primitives::Primitives;
use std::future::Ready;
use zenoh_core::{zread, AsyncResolve, Resolvable, Resolve, SyncResolve};
use zenoh_keyexpr::keyexpr;
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/primitives/query.rs → zenoh/src/api/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//

//! Query primitives.
use crate::primitives::{
use crate::api::{
encoding::Encoding,
handlers::{locked, Callback, DefaultHandler, IntoHandler},
key_expr::KeyExpr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
//

//! Queryable primitives.
use crate::net::primitives::Primitives;
use crate::primitives::{
use crate::api::{
encoding::Encoding,
handlers::{locked, DefaultHandler, IntoHandler},
key_expr::KeyExpr,
Expand All @@ -33,6 +32,7 @@ use crate::primitives::{
value::Value,
Id,
};
use crate::net::primitives::Primitives;
use std::fmt;
use std::future::Ready;
use std::ops::Deref;
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/primitives/sample.rs → zenoh/src/api/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//

//! Sample primitives
use crate::primitives::{
use crate::api::{
encoding::Encoding,
key_expr::KeyExpr,
payload::Payload,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>
//
use crate::primitives::{
use crate::api::{
encoding::Encoding,
key_expr::KeyExpr,
payload::Payload,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>
//
use crate::api::handlers::{locked, Callback, DefaultHandler, IntoHandler};
use crate::net::runtime::{orchestrator::Loop, Runtime};
use crate::primitives::handlers::{locked, Callback, DefaultHandler, IntoHandler};

use futures::StreamExt;
use std::{fmt, future::Ready, net::SocketAddr, ops::Deref};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

//! [Selector](https://github.com/eclipse-zenoh/roadmap/tree/main/rfcs/ALL/Selectors) to issue queries
use crate::primitives::{
key_expr::KeyExpr, query::_REPLY_KEY_EXPR_ANY_SEL_PARAM, queryable::Query,
};
use crate::api::{key_expr::KeyExpr, query::_REPLY_KEY_EXPR_ANY_SEL_PARAM, queryable::Query};
use std::{
borrow::{Borrow, Cow},
collections::HashMap,
Expand Down
8 changes: 4 additions & 4 deletions zenoh/src/primitives/session.rs → zenoh/src/api/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>
//
use crate::net::{primitives::Primitives, routing::dispatcher::face::Face, runtime::Runtime};
use crate::primitives::liveliness::PREFIX_LIVELINESS;
use crate::primitives::{
use crate::api::liveliness::PREFIX_LIVELINESS;
use crate::api::{
admin,
encoding::Encoding,
handlers::{Callback, DefaultHandler},
Expand All @@ -32,6 +31,7 @@ use crate::primitives::{
value::Value,
Id,
};
use crate::net::{primitives::Primitives, routing::dispatcher::face::Face, runtime::Runtime};
use log::{error, trace, warn};
use std::collections::HashMap;
use std::convert::TryFrom;
Expand Down Expand Up @@ -1228,7 +1228,7 @@ impl Session {
&self,
key_expr: &KeyExpr,
) -> ZResult<Arc<LivelinessTokenState>> {
use crate::primitives::liveliness::KE_PREFIX_LIVELINESS;
use crate::api::liveliness::KE_PREFIX_LIVELINESS;

let mut state = zwrite!(self.state);
log::trace!("declare_liveliness({:?})", key_expr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//

//! Subscribing primitives.
use crate::primitives::{
use crate::api::{
handlers::{locked, Callback, DefaultHandler, IntoHandler},
key_expr::KeyExpr,
sample::{Locality, Sample},
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion zenoh/src/primitives/value.rs → zenoh/src/api/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//

//! Value primitives.
use crate::primitives::{encoding::Encoding, payload::Payload, sample::builder::ValueBuilderTrait};
use crate::api::{encoding::Encoding, payload::Payload, sample::builder::ValueBuilderTrait};

/// A zenoh [`Value`] contains a `payload` and an [`Encoding`] that indicates how the [`Payload`] should be interpreted.
#[non_exhaustive]
Expand Down
47 changes: 38 additions & 9 deletions zenoh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,54 @@ pub const FEATURES: &str = concat_enabled_features!(
pub mod prelude;
pub use prelude::common::*;

mod api;
mod net;
mod plugins;
mod primitives;

pub use zenoh_result::ZResult as Result;

pub mod session {
pub use crate::primitives::session::open;
pub use crate::primitives::session::Session;
pub use crate::primitives::session::SessionDeclarations;
pub use crate::api::session::open;
pub use crate::api::session::Session;
pub use crate::api::session::SessionDeclarations;
}

pub mod key_expr {
pub use zenoh_keyexpr::*;
pub use zenoh_macros::kedefine;
pub use zenoh_macros::keformat;
}

pub mod sample {
pub use crate::primitives::sample::builder::{
pub use crate::api::sample::builder::{
QoSBuilderTrait, SampleBuilderTrait, TimestampBuilderTrait, ValueBuilderTrait,
};
#[zenoh_macros::unstable]
pub use crate::primitives::sample::Attachment;
pub use crate::api::sample::Attachment;
#[zenoh_macros::unstable]
pub use crate::primitives::sample::Locality;
pub use crate::api::sample::Locality;
#[zenoh_macros::unstable]
pub use crate::primitives::sample::SourceInfo;
pub use crate::primitives::sample::{Sample, SampleKind};
pub use crate::api::sample::SourceInfo;
pub use crate::api::sample::{Sample, SampleKind};
}

pub mod queryable {
pub use crate::api::queryable::Query;
}

pub mod query {
pub use crate::api::query::Reply;
}

pub mod publication {
pub use crate::api::publication::Priority;
}

pub mod handlers {
pub use crate::api::handlers::IntoHandler;
pub use crate::api::handlers::RingBuffer;
}

pub mod config {
pub use zenoh_config::*;
}
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/dispatcher/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
use super::super::router::*;
use super::tables::TablesLock;
use super::{resource::*, tables};
use crate::api::key_expr::KeyExpr;
use crate::net::primitives::{McastMux, Mux, Primitives};
use crate::net::routing::interceptor::{InterceptorTrait, InterceptorsChain};
use crate::primitives::key_expr::KeyExpr;
use std::any::Any;
use std::collections::HashMap;
use std::fmt;
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/interceptor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
//! [Click here for Zenoh's documentation](../zenoh/index.html)
use super::RoutingContext;
use crate::{
api::key_expr::KeyExpr,
net::routing::interceptor::downsampling::downsampling_interceptor_factories,
primitives::key_expr::KeyExpr,
};
use std::any::Any;
use zenoh_config::Config;
Expand Down
6 changes: 3 additions & 3 deletions zenoh/src/net/runtime/adminspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
// ZettaScale Zenoh Team, <[email protected]>
use super::routing::dispatcher::face::Face;
use super::Runtime;
use crate::net::primitives::Primitives;
use crate::plugins::sealed as plugins;
use crate::primitives::{
use crate::api::{
encoding::Encoding,
key_expr::KeyExpr,
payload::Payload,
queryable::{Query, QueryInner},
sample::builder::ValueBuilderTrait,
value::Value,
};
use crate::net::primitives::Primitives;
use crate::plugins::sealed as plugins;
use log::{error, trace};
use serde_json::json;
use std::collections::HashMap;
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/plugins/sealed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

//! `zenohd`'s plugin system. For more details, consult the [detailed documentation](https://github.com/eclipse-zenoh/roadmap/blob/main/rfcs/ALL/Plugins/Zenoh%20Plugins.md).
use crate::{net::runtime::Runtime, primitives::selector::Selector};
use crate::{api::selector::Selector, net::runtime::Runtime};
use zenoh_core::zconfigurable;

use zenoh_plugin_trait::{
Expand Down
13 changes: 11 additions & 2 deletions zenoh/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@
//! ```
pub(crate) mod common {
pub use crate::config::{Config, ValidatedMap};

#[zenoh_macros::unstable]
pub use crate::sample::Attachment;
pub use crate::sample::{
QoSBuilderTrait, SampleBuilderTrait, TimestampBuilderTrait, ValueBuilderTrait,
Locality, QoSBuilderTrait, Sample, SampleBuilderTrait, SampleKind, SourceInfo,
TimestampBuilderTrait, ValueBuilderTrait,
};

pub use crate::query::Reply;

pub use crate::session::{open, Session, SessionDeclarations};
pub use zenoh_config::Config;

pub use crate::publication::Priority;

pub use crate::key_expr::kedefine;

// /// A zenoh error.
// // pub use zenoh_result::Error;
Expand Down
1 change: 1 addition & 0 deletions zenoh/tests/connection_retry.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use zenoh::config::ConnectionRetryConf;
use zenoh::prelude::sync::*;
use zenoh_link::EndPoint;

#[test]
fn retry_config_overriding() {
Expand Down
2 changes: 1 addition & 1 deletion zenoh/tests/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// ZettaScale Zenoh Team, <[email protected]>
//
use std::time::Duration;
use zenoh::prelude::r#async::*;
use zenoh::{config, prelude::r#async::*};
use zenoh_core::ztimeout;

const TIMEOUT: Duration = Duration::from_secs(10);
Expand Down
1 change: 1 addition & 0 deletions zenoh/tests/formatters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
#[test]
fn reuse() {
use zenoh::prelude::r#async::*;
zenoh::kedefine!(
pub gkeys: "zenoh/${group:*}/${member:*}",
);
Expand Down
1 change: 1 addition & 0 deletions zenoh/tests/liveliness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// ZettaScale Zenoh Team, <[email protected]>
//
use std::time::Duration;
use zenoh::config;
use zenoh::prelude::r#async::*;
use zenoh_core::ztimeout;

Expand Down
2 changes: 1 addition & 1 deletion zenoh/tests/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::str::FromStr;
use std::time::Duration;
use zenoh::prelude::r#async::*;
use zenoh_core::ztimeout;
use zenoh_result::ZResult as Result;
use zenoh_link::Locator;

const TIMEOUT: Duration = Duration::from_secs(60);
const RECV_TIMEOUT: Duration = Duration::from_secs(1);
Expand Down
2 changes: 0 additions & 2 deletions zenoh/tests/qos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
//
use std::time::Duration;
use zenoh::prelude::r#async::*;
use zenoh::sample::builder::QoSBuilderTrait;
use zenoh::{publication::Priority, SessionDeclarations};
use zenoh_core::ztimeout;

const TIMEOUT: Duration = Duration::from_secs(60);
Expand Down

0 comments on commit 0776580

Please sign in to comment.