Debian Codegraph @

src/eof.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#, ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#, Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#};
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/;
4
5 use craterust-analyzer cargo buffered-reader 1.4.1 crate/::BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#;
6
7 /// Always returns EOF.
8 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
9 pub struct EOFrust-analyzer cargo buffered-reader 1.4.1 eof/EOF#<C> {
10 cookierust-analyzer cargo buffered-reader 1.4.1 eof/EOF#cookie.: C,
11 }
12
13 assert_send_and_syncrust-analyzer cargo buffered-reader 1.4.1 macros/assert_send_and_sync!!(EOFrust-analyzer cargo buffered-reader 1.4.1 eof/EOF#<C>
14 where C: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#);
15
16 impl<C> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for EOFrust-analyzer cargo buffered-reader 1.4.1 eof/EOF#<C> {
17 fn fmtrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
18 f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("EOF")
19 .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().()
20 }
21 }
22
23 impl EOFrust-analyzer cargo buffered-reader 1.4.1 eof/EOF#<()> {
24 /// Instantiates a new `EOF`.
25 pub fn newrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<()>`]new().() -> Selfrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<()>`] {
26 EOFrust-analyzer cargo buffered-reader 1.4.1 eof/EOF# {
27 cookierust-analyzer cargo buffered-reader 1.4.1 eof/EOF#cookie.: (),
28 }
29 }
30 }
31
32 impl<C> EOFrust-analyzer cargo buffered-reader 1.4.1 eof/EOF#<C> {
33 /// Instantiates a new `EOF` with a cookie.
34 pub fn with_cookierust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`]with_cookie().(cookie: C) -> Selfrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`] {
35 EOFrust-analyzer cargo buffered-reader 1.4.1 eof/EOF# {
36 cookierust-analyzer cargo buffered-reader 1.4.1 eof/EOF#cookie.,
37 }
38 }
39 }
40
41 impl<C> Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# for EOFrust-analyzer cargo buffered-reader 1.4.1 eof/EOF#<C> {
42 fn readrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][Read]read().(&mut self, _buf: &mut [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> {
43 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0)
44 }
45 }
46
47 impl<C: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#> BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C> for EOFrust-analyzer cargo buffered-reader 1.4.1 eof/EOF#<C> {
48 fn bufferrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]buffer().(&self) -> &[u8] {
49 &b""[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
50 }
51
52 fn datarust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]data().(&mut self, _amount: usize) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&[u8], iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> {
53 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&b""[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
54 }
55
56 fn consumerust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]consume().(&mut self, amount: usize) -> &[u8] {
57 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(amount, 0);
58 &b""[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
59 }
60
61 fn data_consumerust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]data_consume().(&mut self, _amount: usize) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&[u8], iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> {
62 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&b""[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
63 }
64
65 fn data_consume_hardrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]data_consume_hard().(&mut self, amount: usize) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&[u8], iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> {
66 if amount rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
67 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&b""[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
68 } else {
69 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::UnexpectedEofrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#UnexpectedEof#, "unexpected EOF"))
70 }
71 }
72
73 fn into_innerrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]into_inner().<'a>(self: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Selfrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]>) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C> + 'a>>
74 where Selfrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]: 'a
75 {
76 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
77 }
78
79 fn get_mutrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]get_mut().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut dyn BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C>>
80 {
81 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
82 }
83
84 fn get_refrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]get_ref().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&dyn BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C>>
85 {
86 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
87 }
88
89
90 fn cookie_setrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]cookie_set().(&mut self, cookie: C) -> C {
91 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/;
92
93 memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::replacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/replace().(&mut self.cookierust-analyzer cargo buffered-reader 1.4.1 eof/EOF#cookie., cookie)
94 }
95
96 fn cookie_refrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]cookie_ref().(&self) -> &C {
97 &self.cookierust-analyzer cargo buffered-reader 1.4.1 eof/EOF#cookie.
98 }
99
100 fn cookie_mutrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]cookie_mut().(&mut self) -> &mut C {
101 &mut self.cookierust-analyzer cargo buffered-reader 1.4.1 eof/EOF#cookie.
102 }
103 }
104
105 #[cfg(test)]
106 mod testrust-analyzer cargo buffered-reader 1.4.1 eof/test/ {
107 use superrust-analyzer cargo buffered-reader 1.4.1 eof/::*;
108
109 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
110 fn basicsrust-analyzer cargo buffered-reader 1.4.1 eof/test/basics().() {
111 let mut reader = EOFrust-analyzer cargo buffered-reader 1.4.1 eof/EOF#::newrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<()>`]new().();
112
113 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.bufferrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]buffer().(), &b""[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
114 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.datarust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]data().(100).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), &b""[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
115 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.bufferrust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]buffer().(), &b""[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
116 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.consumerust-analyzer cargo buffered-reader 1.4.1 eof/impl#[`EOF<C>`][`BufferedReader<C>`]consume().(0), &b""[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
117 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.data_hardrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data_hard().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), &b""[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
118 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(reader.data_hardrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data_hard().(1).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
119 }
120 }