| 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 | |
| 3 | use superrust-analyzer cargo buffered-reader 1.4.1 crate/::*; |
| 4 | |
| 5 | /// Changes the cookie type without introducing any buffering. |
| 6 | /// |
| 7 | /// If you have a `b: BufferedReader<B>` but need a `c: |
| 8 | /// BufferedReader<C>`, then one way to do that is to use `let c = |
| 9 | /// Generic::with_cookie(b, _)`, but that introduces buffering. This |
| 10 | /// `Adapter` also changes cookie types, but does no buffering of its |
| 11 | /// own. |
| 12 | #[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:)] |
| 13 | pub struct Adapterrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#<T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<B>, B: 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# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#, 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#> { |
| 14 | _ghostly_cookierust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#_ghostly_cookie.: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<B>, |
| 15 | cookierust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#cookie.: C, |
| 16 | readerrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#reader.: T, |
| 17 | } |
| 18 | |
| 19 | assert_send_and_syncrust-analyzer cargo buffered-reader 1.4.1 macros/assert_send_and_sync!!(Adapterrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#<T, B, C> |
| 20 | where T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<B>, |
| 21 | B: 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#, |
| 22 | 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#); |
| 23 | |
| 24 | impl<T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<B>, B: 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# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#, 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#> 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 Adapterrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#<T, B, C> { |
| 25 | fn fmtrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, 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# { |
| 26 | f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Adapter").finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().() |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | impl<T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<B>, B: 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#> Adapterrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#<T, B, ()> { |
| 31 | /// Instantiates a new adapter. |
| 32 | /// |
| 33 | /// `reader` is the source to wrap. |
| 34 | pub fn newrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, ()>`]new().(reader: T) -> Selfrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, ()>`] { |
| 35 | Selfrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, ()>`]::with_cookierust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, C>`]with_cookie().(reader, ()) |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | impl<T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<B>, B: 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# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#, 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#> Adapterrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#<T, B, C> { |
| 40 | /// Like [`Self::new`], but sets a cookie. |
| 41 | /// |
| 42 | /// The cookie can be retrieved using the [`BufferedReader::cookie_ref`] and |
| 43 | /// [`BufferedReader::cookie_mut`] methods, and set using the [`BufferedReader::cookie_set`] method. |
| 44 | pub fn with_cookierust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, C>`]with_cookie().(reader: T, cookie: C) |
| 45 | -> Adapterrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#<T, B, C> { |
| 46 | Adapterrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter# { |
| 47 | readerrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#reader., |
| 48 | _ghostly_cookierust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#_ghostly_cookie.: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/impl#[`PhantomData<T>`][Default]default().(), |
| 49 | cookierust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#cookie., |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | impl<T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<B>, B: 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# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#, 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#> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# for Adapterrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#<T, B, C> { |
| 55 | fn readrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, 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#> { |
| 56 | self.readerrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#reader..readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read().(buf) |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | impl<T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<B>, B: 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# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#, 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 Adapterrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#<T, B, C> { |
| 61 | fn bufferrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, C>`][`BufferedReader<C>`]buffer().(&self) -> &[u8] { |
| 62 | self.readerrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#reader..bufferrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#buffer().() |
| 63 | } |
| 64 | |
| 65 | fn datarust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, 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#> { |
| 66 | self.readerrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#reader..datarust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data().(amount) |
| 67 | } |
| 68 | |
| 69 | fn consumerust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, C>`][`BufferedReader<C>`]consume().(&mut self, amount: usize) -> &[u8] { |
| 70 | self.readerrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#reader..consumerust-analyzer cargo buffered-reader 1.4.1 BufferedReader#consume().(amount) |
| 71 | } |
| 72 | |
| 73 | fn data_consumerust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, 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#> { |
| 74 | self.readerrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#reader..data_consumerust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data_consume().(amount) |
| 75 | } |
| 76 | |
| 77 | fn data_consume_hardrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, 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#> { |
| 78 | self.readerrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#reader..data_consume_hardrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data_consume_hard().(amount) |
| 79 | } |
| 80 | |
| 81 | fn consummatedrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, C>`][`BufferedReader<C>`]consummated().(&mut self) -> bool { |
| 82 | self.readerrust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#reader..consummatedrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#consummated().() |
| 83 | } |
| 84 | |
| 85 | fn get_mutrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, 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>> { |
| 86 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 87 | } |
| 88 | |
| 89 | fn get_refrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, 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>> { |
| 90 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 91 | } |
| 92 | |
| 93 | fn into_innerrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, C>`][`BufferedReader<C>`]into_inner().<'b>(self: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Selfrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, 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> + 'b>> |
| 94 | where Selfrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, C>`][`BufferedReader<C>`]: 'b { |
| 95 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 96 | } |
| 97 | |
| 98 | fn cookie_setrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, C>`][`BufferedReader<C>`]cookie_set().(&mut self, cookie: C) -> C { |
| 99 | 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/::replacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/replace().(&mut self.cookierust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#cookie., cookie) |
| 100 | } |
| 101 | |
| 102 | fn cookie_refrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, C>`][`BufferedReader<C>`]cookie_ref().(&self) -> &C { |
| 103 | &self.cookierust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#cookie. |
| 104 | } |
| 105 | |
| 106 | fn cookie_mutrust-analyzer cargo buffered-reader 1.4.1 adapter/impl#[`Adapter<T, B, C>`][`BufferedReader<C>`]cookie_mut().(&mut self) -> &mut C { |
| 107 | &mut self.cookierust-analyzer cargo buffered-reader 1.4.1 adapter/Adapter#cookie. |
| 108 | } |
| 109 | } |