Debian Codegraph @

src/buffer/mod.rs

raw symbols SCIP
1 #![allow(missing_docs)]
2
3 mod std_bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/;
4
5 #[cfg(feature = "slice-deque")]
6 mod slice_deque_buf;
7
8 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#;
9
10 use selfrust-analyzer cargo buffer-redux 1.1.0 buffer/::std_bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/::StdBufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#;
11
12 #[cfg(feature = "slice-deque")]
13 use selfrust-analyzer cargo buffer-redux 1.1.0 buffer/::slice_deque_buf::SliceDequeBuf;
14
15 pub enum BufImplrust-analyzer cargo buffer-redux 1.1.0 buffer/BufImpl# {
16 Stdrust-analyzer cargo buffer-redux 1.1.0 buffer/BufImpl#Std#(StdBufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#),
17 #[cfg(feature = "slice-deque")]
18 Ringbuf(SliceDequeBuf),
19 }
20
21 macro_rules! forward_methodrust-analyzer cargo buffer-redux 1.1.0 buffer/forward_method! {
22 ($(#[$m:meta])*
23 pub fn $fnname:ident(&self $($args:tt)*) [$($passargs:tt)*] $(-> $ret:ty)*) => {
24 $(#[$m])*
25 pub fn $fnname(&self $($args)*) $(-> $ret)* {
26 match *self {
27 BufImpl::Std(ref buf) => buf.$fnname($($passargs)*),
28 #[cfg(feature = "slice-deque")]
29 BufImpl::Ringbuf(ref buf) => buf.$fnname($($passargs)*),
30 }
31 }
32 };
33
34 ($(#[$m:meta])*
35 pub fn $fnname:ident(&mut self $($args:tt)*) [$($passargs:tt)*] $(-> $ret:ty)*) => {
36 $(#[$m])*
37 pub fn $fnname(&mut self $($args)*) $(-> $ret)* {
38 match *self {
39 BufImpl::Std(ref mut buf) => buf.$fnname($($passargs)*),
40 #[cfg(feature = "slice-deque")]
41 BufImpl::Ringbuf(ref mut buf) => buf.$fnname($($passargs)*),
42 }
43 }
44 };
45
46 ($(#[$m:meta])*
47 pub unsafe fn $fnname:ident(&self $($args:tt)*) [$($passargs:tt)*] $(-> $ret:ty)*) => {
48 $(#[$m])*
49 pub unsafe fn $fnname(&self $($args)*) $(-> $ret)* {
50 match *self {
51 BufImpl::Std(ref buf) => buf.$fnname($($passargs)*),
52 #[cfg(feature = "slice-deque")]
53 BufImpl::Ringbuf(ref buf) => buf.$fnname($($passargs)*),
54 }
55 }
56 };
57
58 ($(#[$m:meta])*
59 pub unsafe fn $fnname:ident(&mut self $($args:tt)*) [$($passargs:tt)*] $(-> $ret:ty)*) => {
60 $(#[$m])*
61 pub unsafe fn $fnname(&mut self $($args)*) $(-> $ret)* {
62 match *self {
63 BufImpl::Std(ref mut buf) => buf.$fnname($($passargs)*),
64 #[cfg(feature = "slice-deque")]
65 BufImpl::Ringbuf(ref mut buf) => buf.$fnname($($passargs)*),
66 }
67 }
68 };
69 }
70
71 macro_rules! forward_methodsrust-analyzer cargo buffer-redux 1.1.0 buffer/forward_methods! {
72 ($($(#[$m:meta])*
73 $($qualifiers:ident)+ ($($args:tt)*) [$($passargs:tt)*] $(-> $ret:ty)*);+;) => (
74 $(forward_method! {
75 $(#[$m])* $($qualifiers)+ ($($args)*) [$($passargs)*] $(-> $ret)*
76 })*
77 )
78 }
79
80 impl BufImplrust-analyzer cargo buffer-redux 1.1.0 buffer/BufImpl# {
81 pub fn with_capacityrust-analyzer cargo buffer-redux 1.1.0 buffer/impl#[BufImpl]with_capacity().(cap: usize) -> Selfrust-analyzer cargo buffer-redux 1.1.0 buffer/impl#[BufImpl] {
82 BufImplrust-analyzer cargo buffer-redux 1.1.0 buffer/BufImpl#::Stdrust-analyzer cargo buffer-redux 1.1.0 buffer/BufImpl#Std#(StdBufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#::with_capacityrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]with_capacity().(cap))
83 }
84
85 #[cfg(feature = "slice-deque")]
86 pub fn with_capacity_ringbuf(cap: usize) -> Selfrust-analyzer cargo buffer-redux 1.1.0 buffer/impl#[BufImpl] {
87 BufImplrust-analyzer cargo buffer-redux 1.1.0 buffer/BufImpl#::Ringbuf(SliceDequeBuf::with_capacity(cap))
88 }
89
90 pub fn is_ringbufrust-analyzer cargo buffer-redux 1.1.0 buffer/impl#[BufImpl]is_ringbuf().(&self) -> bool {
91 match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self {
92 #[cfg(feature = "slice-deque")]
93 BufImplrust-analyzer cargo buffer-redux 1.1.0 buffer/BufImpl#::Ringbuf(_) => true,
94 _ => false,
95 }
96 }
97
98 forward_methodsrust-analyzer cargo buffer-redux 1.1.0 buffer/forward_methods!! {
99 pub fn capacityrust-analyzer cargo buffer-redux 1.1.0 buffer/impl#[BufImpl]capacity().(&self)[] -> usize;
100
101 pub fn lenrust-analyzer cargo buffer-redux 1.1.0 buffer/impl#[BufImpl]len().(&self)[] -> usize;
102
103 pub fn usable_spacerust-analyzer cargo buffer-redux 1.1.0 buffer/impl#[BufImpl]usable_space().(&self)[] -> usize;
104
105 pub fn reserverust-analyzer cargo buffer-redux 1.1.0 buffer/impl#[BufImpl]reserve().(&mut self, additional: usize)[additional] -> bool;
106
107 pub fn make_roomrust-analyzer cargo buffer-redux 1.1.0 buffer/impl#[BufImpl]make_room().(&mut self)[];
108
109 #[inline]
110 pub fn bufrust-analyzer cargo buffer-redux 1.1.0 buffer/impl#[BufImpl]buf().(&self)[] -> &[u8];
111
112 pub fn buf_mutrust-analyzer cargo buffer-redux 1.1.0 buffer/impl#[BufImpl]buf_mut().(&mut self)[] -> &mut [u8];
113
114 pub unsafe fn write_bufrust-analyzer cargo buffer-redux 1.1.0 buffer/impl#[BufImpl]write_buf().(&mut self)[] -> &mut [MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#<u8>];
115
116 pub unsafe fn bytes_writtenrust-analyzer cargo buffer-redux 1.1.0 buffer/impl#[BufImpl]bytes_written().(&mut self, add: usize)[add];
117
118 pub fn consumerust-analyzer cargo buffer-redux 1.1.0 buffer/impl#[BufImpl]consume().(&mut self, amt: usize)[amt];
119 }
120 }