async_mtzip/zip/
mod.rs

1pub mod data;
2pub mod extra_field;
3pub mod file;
4pub mod job;
5pub mod crc32;
6pub mod level;
7
8use std::io::Seek;
9use tokio::io::{AsyncSeek, AsyncSeekExt};
10
11#[inline]
12pub fn stream_position_u32<W: Seek>(buf: &mut W) -> std::io::Result<u32> {
13    let offset = buf.stream_position()?;
14    debug_assert!(offset <= u32::MAX.into());
15    Ok(offset as u32)
16}
17
18#[inline]
19pub async fn stream_position_u32_with_tokio<W: AsyncSeek + Unpin>(buf: &mut W) -> std::io::Result<u32> {
20    let offset = buf.stream_position().await?;
21    debug_assert!(offset <= u32::MAX.into());
22    Ok(offset as u32)
23}
24
25#[inline]
26pub fn files_amount_u16<T>(files: &[T]) -> u16 {
27    let amount = files.len();
28    debug_assert!(amount <= u16::MAX as usize);
29    amount as u16
30}