Debian Codegraph @

src/tokio/mod.rs

raw symbols SCIP
1 // Copyright (c) 2023 Harry [Majored] [[email protected]]
2 // MIT License (https://github.com/Majored/rs-async-zip/blob/main/LICENSE)
3
4 //! A set of [`tokio`]-specific type aliases and features.
5 //!
6 //! # Usage
7 //! With the `tokio` feature enabled, types from the [`base`] implementation will implement additional constructors
8 //! for use with [`tokio`]. These constructors internally implement conversion between the required async IO traits.
9 //! They are defined as:
10 //! - [`base::read::seek::ZipFileReader::with_tokio()`]
11 //! - [`base::read::stream::ZipFileReader::with_tokio()`]
12 //! - [`base::write::ZipFileWriter::with_tokio()`]
13 //!
14 //! As a result of Rust's type inference, we are able to reuse the [`base`] implementation's types with considerable
15 //! ease. There only exists one caveat with their use; the types returned by these constructors contain a wrapping
16 //! compatibility type provided by an external crate. These compatibility types cannot be named unless you also pull in
17 //! the [`tokio_util`] dependency manually. This is why we've provided type aliases within this module so that they can
18 //! be named without needing to pull in a separate dependency.
19
20 #[cfg(doc)]
21 use crate::base;
22 #[cfg(doc)]
23 use tokio;
24 #[cfg(doc)]
25 use tokio_util;
26
27 pub mod read;
28
29 pub mod write {
30 //! A module which supports writing ZIP files.
31
32 #[cfg(doc)]
33 use crate::base;
34 use tokio_util::compat::Compat;
35
36 /// A [`tokio`]-specific type alias for [`base::write::ZipFileWriter`];
37 pub type ZipFileWriter<W> = crate::base::write::ZipFileWriter<Compat<W>>;
38
39 /// A [`tokio`]-specific type alias for [`base::write::EntryStreamWriter`];
40 pub type EntryStreamWriter<'a, W> = crate::base::write::EntryStreamWriter<'a, Compat<W>>;
41 }