forked from eclipse-zenoh/zenoh-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
137 lines (126 loc) · 4.13 KB
/
Copy pathlib.rs
File metadata and controls
137 lines (126 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//
// Copyright (c) 2024 ZettaScale Technology
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//
// TODO https://github.com/eclipse-zenoh/zenoh-python/pull/235#discussion_r1644498390
// mod logging;
mod bytes;
mod cancellation;
mod config;
#[cfg(feature = "zenoh-ext")]
mod ext;
mod handlers;
mod key_expr;
mod liveliness;
mod macros;
mod matching;
mod pubsub;
mod qos;
mod query;
mod sample;
mod scouting;
mod session;
#[cfg(feature = "shared-memory")]
mod shm;
mod time;
mod timestamp_stack;
mod utils;
use pyo3::prelude::*;
pyo3::create_exception!(zenoh, ZError, pyo3::exceptions::PyException);
// must be defined here or exporting doesn't work
#[cfg(feature = "zenoh-ext")]
pyo3::create_exception!(zenoh, ZDeserializeError, pyo3::exceptions::PyException);
#[pymodule]
pub(crate) mod zenoh {
use pyo3::prelude::*;
#[pyfunction]
fn try_init_log_from_env() {
zenoh::try_init_log_from_env();
}
#[pyfunction]
fn init_log_from_env_or(level: &str) {
zenoh::init_log_from_env_or(level);
}
#[pymodule_export]
use crate::{
bytes::{Encoding, ZBytes},
cancellation::CancellationToken,
config::{Config, WhatAmI, WhatAmIMatcher, ZenohId},
handlers::Handler,
key_expr::{KeyExpr, SetIntersectionLevel},
liveliness::{Liveliness, LivelinessToken},
matching::{MatchingListener, MatchingStatus},
pubsub::{Publisher, Subscriber},
qos::{CongestionControl, Priority, Reliability},
query::{
ConsolidationMode, Parameters, Querier, Query, QueryConsolidation, QueryTarget,
Queryable, Reply, ReplyError, ReplyKeyExpr, Selector,
},
sample::{Locality, Sample, SampleKind, SourceInfo},
scouting::{scout, Hello, Scout},
session::{
open, EntityGlobalId, Link, LinkEvent, LinkEventsListener, Session, SessionInfo,
Transport, TransportEvent, TransportEventsListener,
},
time::{Timestamp, TimestampId, NTP64},
timestamp_stack::{
InterceptionPoint, TimestampInstrumentation, TimestampInstrumentationBuilder,
TimestampStack, TimestampStackRecord, TsStackContext,
},
ZError,
};
#[pymodule]
mod handlers {
#[pymodule_export]
use crate::handlers::{Callback, DefaultHandler, FifoChannel, Handler, RingChannel};
}
#[cfg(feature = "zenoh-ext")]
#[pymodule]
mod _ext {
#[pymodule_export]
use crate::{
ext::{
declare_advanced_publisher, declare_advanced_subscriber, z_deserialize,
z_serialize, AdvancedPublisher, AdvancedSubscriber, CacheConfig, HistoryConfig,
Miss, MissDetectionConfig, RecoveryConfig, RepliesConfig, SampleMissListener,
},
ZDeserializeError,
};
}
#[cfg(feature = "shared-memory")]
#[pymodule]
mod shm {
#[pymodule_export]
use crate::shm::{
AllocAlignment, BlockOn, Deallocate, Defragment, GarbageCollect, JustAlloc,
MemoryLayout, ShmProvider, ZShm, ZShmMut,
};
}
#[pymodule_init]
fn init(m: &Bound<'_, PyModule>) -> PyResult<()> {
let sys_modules = m.py().import("sys")?.getattr("modules")?;
sys_modules.set_item("zenoh.handlers", m.getattr("handlers")?)?;
#[cfg(feature = "zenoh-ext")]
sys_modules.set_item("zenoh._ext", m.getattr("_ext")?)?;
#[cfg(feature = "shared-memory")]
sys_modules.set_item("zenoh.shm", m.getattr("shm")?)?;
// TODO
// crate::logging::init_logger(m.py())?;
Ok(())
}
}
// Test should be runned with `cargo test --no-default-features`
#[test]
#[cfg(not(feature = "default"))]
fn test_no_default_features() {
assert_eq!(::zenoh::FEATURES, " zenoh/unstable");
}