Skip to content

Commit

Permalink
fmt and fix io::Write impl
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Nov 19, 2021
1 parent e52f095 commit 90f7392
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
5 changes: 4 additions & 1 deletion digest/src/core_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
//! core algorithm wrapped by the wrapper types, which implement the
//! higher-level traits.
use crate::InvalidOutputSize;
use generic_array::{ArrayLength, typenum::{U256, IsLess, Le, NonZero}};
use generic_array::{
typenum::{IsLess, Le, NonZero, U256},
ArrayLength,
};

pub use crypto_common::{AlgorithmName, Block, BlockSizeUser, OutputSizeUser, Reset};

Expand Down
2 changes: 1 addition & 1 deletion digest/src/core_api/ct_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::MacMarker;
use core::{fmt, marker::PhantomData};
use crypto_common::{Block, BlockSizeUser, OutputSizeUser};
use generic_array::{
typenum::{IsLessOrEqual, IsLess, Le, LeEq, NonZero, U256},
typenum::{IsLess, IsLessOrEqual, Le, LeEq, NonZero, U256},
ArrayLength, GenericArray,
};

Expand Down
8 changes: 5 additions & 3 deletions digest/src/core_api/rt_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::MacMarker;
use crate::{InvalidOutputSize, Reset, Update, VariableOutput};
use block_buffer::BlockBuffer;
use core::fmt;
use generic_array::typenum::{Unsigned, Le, IsLess, U256, NonZero};
use generic_array::typenum::{IsLess, Le, NonZero, Unsigned, U256};

/// Wrapper around [`VariableOutputCore`] which selects output size
/// at run time.
Expand All @@ -26,7 +26,8 @@ where
T: VariableOutputCore + HashMarker,
T::BlockSize: IsLess<U256>,
Le<T::BlockSize, U256>: NonZero,
{}
{
}

#[cfg(feature = "mac")]
#[cfg_attr(docsrs, doc(cfg(feature = "mac")))]
Expand All @@ -35,7 +36,8 @@ where
T: VariableOutputCore + MacMarker,
T::BlockSize: IsLess<U256>,
Le<T::BlockSize, U256>: NonZero,
{}
{
}

impl<T> Reset for RtVariableCoreWrapper<T>
where
Expand Down
20 changes: 14 additions & 6 deletions digest/src/core_api/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use super::{
use crate::{ExtendableOutput, FixedOutput, FixedOutputReset, HashMarker, Update};
use block_buffer::BlockBuffer;
use core::fmt;
use crypto_common::{InvalidLength, Key, KeyInit, KeySizeUser, Output, BlockSizeUser};
use generic_array::typenum::{NonZero, IsLess, Le, U256};
use crypto_common::{BlockSizeUser, InvalidLength, Key, KeyInit, KeySizeUser, Output};
use generic_array::typenum::{IsLess, Le, NonZero, U256};

#[cfg(feature = "mac")]
use crate::MacMarker;
Expand All @@ -30,7 +30,8 @@ where
T: BufferKindUser + HashMarker,
T::BlockSize: IsLess<U256>,
Le<T::BlockSize, U256>: NonZero,
{}
{
}

#[cfg(feature = "mac")]
#[cfg_attr(docsrs, doc(cfg(feature = "mac")))]
Expand All @@ -39,7 +40,8 @@ where
T: BufferKindUser + MacMarker,
T::BlockSize: IsLess<U256>,
Le<T::BlockSize, U256>: NonZero,
{}
{
}

impl<T> CoreWrapper<T>
where
Expand Down Expand Up @@ -196,7 +198,12 @@ where

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl<D: UpdateCore + BufferKindUser> std::io::Write for CoreWrapper<D> {
impl<T> std::io::Write for CoreWrapper<T>
where
T: BufferKindUser + UpdateCore,
T::BlockSize: IsLess<U256>,
Le<T::BlockSize, U256>: NonZero,
{
#[inline]
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
Update::update(self, buf);
Expand Down Expand Up @@ -226,7 +233,8 @@ where
T: BufferKindUser,
T::BlockSize: IsLess<U256>,
Le<T::BlockSize, U256>: NonZero,
{}
{
}

impl<T> CoreProxy for CoreWrapper<T>
where
Expand Down
2 changes: 1 addition & 1 deletion digest/src/core_api/xof_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{AlgorithmName, XofReaderCore};
use crate::XofReader;
use block_buffer::EagerBuffer;
use core::fmt;
use generic_array::typenum::{IsLess, Le, U256, NonZero};
use generic_array::typenum::{IsLess, Le, NonZero, U256};

/// Wrapper around [`XofReaderCore`] implementations.
///
Expand Down

0 comments on commit 90f7392

Please sign in to comment.