rtsc/
lib.rs

1#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "README.md" ) ) ]
2#![deny(missing_docs)]
3/// Data buffer
4pub mod buf;
5/// Cell synchronization
6pub mod cell;
7/// Sync channel
8pub mod channel;
9/// Async channel
10pub mod channel_async;
11/// Data policies
12pub mod data_policy;
13/// Event map
14pub mod event_map;
15/// Priority-inverting-safe locking (Linux only)
16#[cfg(target_os = "linux")]
17pub mod pi;
18/// Policy-based sync channel
19pub mod policy_channel;
20/// Policy-based async channel
21pub mod policy_channel_async;
22#[cfg(not(target_os = "linux"))]
23pub use parking_lot_rt as locking;
24#[cfg(target_os = "linux")]
25pub use pi as locking;
26/// Semaphore
27pub mod semaphore;
28/// System tools
29pub mod system;
30/// Time tools
31pub mod time;
32/// Timestamps
33pub use bma_ts;
34/// Base channel type, allows to build sync channels with a custom storage
35pub mod base_channel;
36/// Base async channel type, allows to build async channels with a custom storage
37pub mod base_channel_async;
38/// Conditional traits
39pub mod condvar_api;
40/// Time-limited operations
41pub mod ops;
42/// Policy-based deque
43pub mod pdeque;
44/// Thread scheduling
45pub mod thread_rt;
46
47pub use base_channel::DataChannel;
48
49pub use rtsc_derive::DataPolicy;
50
51/// Error type
52#[derive(thiserror::Error, Debug)]
53pub enum Error {
54    /// the channel is full and the value can not be sent
55    #[error("channel full")]
56    ChannelFull,
57    /// the channel is full, an optional value is skipped. the error can be ignored but should be
58    /// logged
59    #[error("channel message skipped")]
60    ChannelSkipped,
61    /// Channel/cell is closed
62    #[error("channel closed")]
63    ChannelClosed,
64    /// Channel/cell is empty
65    #[error("channel closed")]
66    ChannelEmpty,
67    /// The requested operation is not implemented
68    #[error("not implemented")]
69    Unimplemented,
70    /// Timeouts
71    #[error("timed out")]
72    Timeout,
73    /// Invalid data receied / parameters provided
74    #[error("Invalid data")]
75    InvalidData(String),
76    /// All other errors
77    #[error("operation failed: {0}")]
78    Failed(String),
79    /// System call or internal API access denied
80    #[error("access denied")]
81    AccessDenied,
82    /// I/O errors
83    #[error("I/O error: {0}")]
84    IO(#[from] std::io::Error),
85    /// CPU affinity set error
86    #[error("CPU affinity set error: {0}")]
87    RTSchedSetAffinity(String),
88    /// Real-time priority set error
89    #[error("Real-time priority set error: {0}")]
90    RTSchedSetScheduler(String),
91}
92
93/// Result type
94pub type Result<T> = std::result::Result<T, Error>;