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
#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "README.md" ) ) ]
#![deny(missing_docs)]
/// Data buffer
pub mod buf;
/// Cell synchronization
pub mod cell;
/// Channel
pub mod channel;
/// Data policies
pub mod data_policy;
/// Policy-based channel
pub mod pchannel;
/// Semaphore
pub mod semaphore;
/// Time tools
pub mod time;
/// Locking primitives
pub use parking_lot_rt as locking;
/// Policy-based deque
pub mod pdeque;

mod base_channel;

pub use base_channel::DataChannel;

pub use rtsc_derive::DataPolicy;

/// Error type
#[derive(thiserror::Error, Debug)]
pub enum Error {
    /// the channel is full and the value can not be sent
    #[error("channel full")]
    ChannelFull,
    /// the channel is full, an optional value is skipped. the error can be ignored but should be
    /// logged
    #[error("channel message skipped")]
    ChannelSkipped,
    /// Channel/cell is closed
    #[error("channel closed")]
    ChannelClosed,
    /// Channel/cell is empty
    #[error("channel closed")]
    ChannelEmpty,
    /// The requested operation is not implemented
    #[error("not implemented")]
    Unimplemented,
    /// Timeouts
    #[error("timed out")]
    Timeout,
    /// Invalid data receied / parameters provided
    #[error("Invalid data")]
    InvalidData(String),
}

/// Result type
pub type Result<T> = std::result::Result<T, Error>;