Debian Codegraph @

src/base/write/io/offset.rs

raw symbols SCIP
1 // Copyright (c) 2022 Harry [Majored] [[email protected]]
2 // MIT License (https://github.com/Majored/rs-async-zip/blob/main/LICENSE)
3
4 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#, IoSlicerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/IoSlice#};
5 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/::Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#;
6 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::taskrust-analyzer cargo std https://github.com/rust-lang/rust/library/std task/::{Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#, Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#};
7
8 use futures_literust-analyzer cargo futures-lite 2.1.0 crate/::iorust-analyzer cargo futures-lite 2.1.0 io/::AsyncWriterust-analyzer cargo futures-io 0.3.25 if_std/AsyncWrite#;
9 use pin_projectrust-analyzer cargo pin-project 1.0.12 crate/::pin_projectrust-analyzer cargo pin-project-internal 1.0.12 pin_project:;
10
11 /// A wrapper around an [`AsyncWrite`] implementation which tracks the current byte offset.
12 #[pin_projectrust-analyzer cargo pin-project-internal 1.0.12 pin_project:(project = OffsetWriterProjrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/OffsetWriterProj#)]
13 pub struct AsyncOffsetWriterrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/AsyncOffsetWriter#<W> {
14 #[pinrust-analyzer cargo pin-project-internal 1.0.12 pin:]
15 innerrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/AsyncOffsetWriter#inner.: W,
16 offsetrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/AsyncOffsetWriter#offset.: u64,
17 }
18
19 impl<W> AsyncOffsetWriterrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/AsyncOffsetWriter#<W>
20 where
21 W: AsyncWriterust-analyzer cargo futures-io 0.3.25 if_std/AsyncWrite# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#,
22 {
23 /// Constructs a new wrapper from an inner [`AsyncWrite`] writer.
24 pub fn newrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`]new().(inner: W) -> Selfrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`] {
25 Selfrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`] { innerrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/AsyncOffsetWriter#inner., offsetrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/AsyncOffsetWriter#offset.: 0 }
26 }
27
28 /// Returns the current byte offset.
29 pub fn offsetrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`]offset().(&self) -> u64 {
30 self.offsetrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/AsyncOffsetWriter#offset.
31 }
32
33 /// Consumes this wrapper and returns the inner [`AsyncWrite`] writer.
34 pub fn into_innerrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`]into_inner().(self) -> W {
35 self.innerrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/AsyncOffsetWriter#inner.
36 }
37
38 pub fn inner_mutrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`]inner_mut().(&mut self) -> &mut W {
39 &mut self.innerrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/AsyncOffsetWriter#inner.
40 }
41 }
42
43 impl<W> AsyncWriterust-analyzer cargo futures-io 0.3.25 if_std/AsyncWrite# for AsyncOffsetWriterrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/AsyncOffsetWriter#<W>
44 where
45 W: AsyncWriterust-analyzer cargo futures-io 0.3.25 if_std/AsyncWrite# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#,
46 {
47 fn poll_writerust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`][AsyncWrite]poll_write().(self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`][AsyncWrite]>, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#, buf: &[u8]) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>> {
48 let this = self.projectrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`]project().();
49 let poll = this.innerrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/OffsetWriterProj#inner..poll_writerust-analyzer cargo futures-io 0.3.25 if_std/AsyncWrite#poll_write().(cx, buf);
50
51 if let Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(inner)) = &poll {
52 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().this.offsetrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/OffsetWriterProj#offset. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().inner as u64;
53 }
54
55 poll
56 }
57
58 fn poll_flushrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`][AsyncWrite]poll_flush().(self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`][AsyncWrite]>, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>> {
59 self.projectrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`]project().().innerrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/OffsetWriterProj#inner..poll_flushrust-analyzer cargo futures-io 0.3.25 if_std/AsyncWrite#poll_flush().(cx)
60 }
61
62 fn poll_closerust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`][AsyncWrite]poll_close().(self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`][AsyncWrite]>, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>> {
63 self.projectrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`]project().().innerrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/OffsetWriterProj#inner..poll_closerust-analyzer cargo futures-io 0.3.25 if_std/AsyncWrite#poll_close().(cx)
64 }
65
66 fn poll_write_vectoredrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`][AsyncWrite]poll_write_vectored().(
67 self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`][AsyncWrite]>,
68 cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>,
69 bufs: &[IoSlicerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/IoSlice#<'_>],
70 ) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>> {
71 self.projectrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/impl#[`AsyncOffsetWriter<W>`]project().().innerrust-analyzer cargo async_zip 0.0.18 base/write/io/offset/OffsetWriterProj#inner..poll_write_vectoredrust-analyzer cargo futures-io 0.3.25 if_std/AsyncWrite#poll_write_vectored().(cx, bufs)
72 }
73 }