| 1 | use craterust-analyzer cargo gix-utils 0.3.5 crate/::Buffersrust-analyzer cargo gix-utils 0.3.5 Buffers#; |
| 2 | |
| 3 | /// Lifecycle |
| 4 | impl Buffersrust-analyzer cargo gix-utils 0.3.5 Buffers# { |
| 5 | /// Use this if there is an input buffer `src` which isn't owned by you, but which should be used as source when |
| 6 | /// asking for [`src_and_dest()`](WithForeignSource::src_and_dest()). |
| 7 | pub fn use_foreign_srcrust-analyzer cargo gix-utils 0.3.5 buffers/impl#[Buffers]use_foreign_src().<'a, 'src>(&'a mut self, src: &'src [u8]) -> WithForeignSourcerust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#<'src, 'a> { |
| 8 | self.clearrust-analyzer cargo gix-utils 0.3.5 buffers/impl#[Buffers]clear().(); |
| 9 | WithForeignSourcerust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource# { |
| 10 | ro_srcrust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#ro_src.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(src), |
| 11 | srcrust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#src.: &mut self.srcrust-analyzer cargo gix-utils 0.3.5 Buffers#src., |
| 12 | destrust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#dest.: &mut self.destrust-analyzer cargo gix-utils 0.3.5 Buffers#dest., |
| 13 | } |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | impl Buffersrust-analyzer cargo gix-utils 0.3.5 Buffers# { |
| 18 | /// Clear all buffers, which should be called once processing is done. |
| 19 | pub fn clearrust-analyzer cargo gix-utils 0.3.5 buffers/impl#[Buffers]clear().(&mut self) { |
| 20 | self.srcrust-analyzer cargo gix-utils 0.3.5 Buffers#src..clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]clear().(); |
| 21 | self.destrust-analyzer cargo gix-utils 0.3.5 Buffers#dest..clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]clear().(); |
| 22 | } |
| 23 | |
| 24 | /// Must be called after every change (i.e. when it's known that `dest` was written. |
| 25 | pub fn swaprust-analyzer cargo gix-utils 0.3.5 buffers/impl#[Buffers]swap().(&mut self) { |
| 26 | 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/::swaprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/swap().(&mut self.srcrust-analyzer cargo gix-utils 0.3.5 Buffers#src., &mut self.destrust-analyzer cargo gix-utils 0.3.5 Buffers#dest.); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | /// A utility to do buffer-swapping with, similar to [`Buffers`], but with support for a |
| 31 | /// read-only one-time buffer as source. |
| 32 | pub struct WithForeignSourcerust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#<'src, 'bufs> { |
| 33 | /// The original source buffer, or `None` if already altered. |
| 34 | pub ro_srcrust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#ro_src.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'src [u8]>, |
| 35 | /// The source buffer that will be used after the first call to `swap`. |
| 36 | pub srcrust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#src.: &'bufs mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, |
| 37 | destrust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#dest.: &'bufs mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, |
| 38 | } |
| 39 | |
| 40 | impl WithForeignSourcerust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#<'_, '_> { |
| 41 | /// Must be called after every change (i.e. when it's known that `dest` was written. |
| 42 | pub fn swaprust-analyzer cargo gix-utils 0.3.5 buffers/impl#[`WithForeignSource<'_, '_>`]swap().(&mut self) { |
| 43 | self.ro_srcrust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#ro_src..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().(); |
| 44 | 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/::swaprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/swap().(&mut self.srcrust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#src., &mut self.destrust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#dest.); |
| 45 | self.destrust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#dest..clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]clear().(); |
| 46 | } |
| 47 | /// Obtain `(source, destination)`, which reads from the read-only source exactly once. |
| 48 | pub fn src_and_destrust-analyzer cargo gix-utils 0.3.5 buffers/impl#[`WithForeignSource<'_, '_>`]src_and_dest().(&mut self) -> (&[u8], &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) { |
| 49 | match self.ro_srcrust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#ro_src. { |
| 50 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(src) => (src, &mut self.destrust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#dest.), |
| 51 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => (self.srcrust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#src., &mut self.destrust-analyzer cargo gix-utils 0.3.5 buffers/WithForeignSource#dest.), |
| 52 | } |
| 53 | } |
| 54 | } |