Debian Codegraph @

src/utils.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 use craterust-analyzer cargo async_zip 0.0.18 crate/::errorrust-analyzer cargo async_zip 0.0.18 error/::{Resultrust-analyzer cargo async_zip 0.0.18 error/Result#, ZipErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#};
5 use futures_literust-analyzer cargo futures-lite 2.1.0 crate/::iorust-analyzer cargo futures-lite 2.1.0 io/::{AsyncReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncRead#, AsyncReadExtrust-analyzer cargo futures-lite 2.1.0 io/AsyncReadExt#};
6
7 // Assert that the next four-byte signature read by a reader which impls AsyncRead matches the expected signature.
8 pub(craterust-analyzer cargo async_zip 0.0.18 crate/) async fn assert_signaturerust-analyzer cargo async_zip 0.0.18 utils/assert_signature().<R: AsyncReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncRead# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#>(reader: &mut R, expected: u32) -> Resultrust-analyzer cargo async_zip 0.0.18 error/Result#<()> {
9 let signature = {
10 let mut buffer = [0; 4];
11 reader.read_exactrust-analyzer cargo futures-lite 2.1.0 io/AsyncReadExt#read_exact().(&mut buffer).rust-analyzer cargo futures-lite 2.1.0 io/impl#[`ReadExactFuture<'_, R>`][Future]poll().awaitrust-analyzer cargo futures-lite 2.1.0 io/impl#[`ReadExactFuture<'_, R>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
12 u32::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_le_bytes().(buffer)
13 };
14 match signature {
15 actual if actual rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().expected => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()),
16 actual => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ZipErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#::UnexpectedHeaderErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#UnexpectedHeaderError#(actual, expected)),
17 }
18 }