slice_ring_buffer/mirrored/
mod.rs

1//! Mirrored memory buffer.
2mod buffer;
3
4#[cfg(all(
5    unix,
6    not(all(
7        any(
8            target_os = "linux",
9            target_os = "android",
10            target_os = "macos",
11            target_os = "ios",
12            target_os = "openbsd"
13        ),
14        not(feature = "unix_sysv")
15    ))
16))]
17mod sysv;
18#[cfg(all(
19    unix,
20    not(all(
21        any(
22            target_os = "linux",
23            target_os = "android",
24            target_os = "macos",
25            target_os = "ios",
26            target_os = "openbsd"
27        ),
28        not(feature = "unix_sysv")
29    ))
30))]
31pub(crate) use self::sysv::{
32    allocate_mirrored, allocation_granularity, deallocate_mirrored,
33};
34
35#[cfg(all(
36    any(target_os = "linux", target_os = "android", target_os = "openbsd"),
37    not(feature = "unix_sysv")
38))]
39mod linux;
40#[cfg(all(
41    any(target_os = "linux", target_os = "android", target_os = "openbsd"),
42    not(feature = "unix_sysv")
43))]
44pub(crate) use self::linux::{
45    allocate_mirrored, allocation_granularity, deallocate_mirrored,
46};
47
48#[cfg(all(
49    any(target_os = "macos", target_os = "ios"),
50    not(feature = "unix_sysv")
51))]
52mod macos;
53
54#[cfg(all(
55    any(target_os = "macos", target_os = "ios"),
56    not(feature = "unix_sysv")
57))]
58pub(crate) use self::macos::{
59    allocate_mirrored, allocation_granularity, deallocate_mirrored,
60};
61
62#[cfg(target_os = "windows")]
63mod winapi;
64
65#[cfg(target_os = "windows")]
66pub(crate) use self::winapi::{
67    allocate_mirrored, allocation_granularity, deallocate_mirrored,
68};
69
70pub use self::buffer::Buffer;
71
72use super::*;
73
74/// Allocation error.
75pub enum AllocError {
76    /// The system is Out-of-memory.
77    Oom,
78    /// Other allocation errors (not out-of-memory).
79    ///
80    /// Race conditions, exhausted file descriptors, etc.
81    Other,
82}
83
84impl crate::fmt::Debug for AllocError {
85    fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
86        match self {
87            AllocError::Oom => write!(f, "out-of-memory"),
88            AllocError::Other => write!(f, "other (not out-of-memory)"),
89        }
90    }
91}