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