Skip to content

Commit

Permalink
Re-export typenum::consts as consts
Browse files Browse the repository at this point in the history
Inspired by the `heapless` crate:

RustCrypto/traits#43 (comment)

This re-export provides convenient access to the type-level numeric
constants provided by `typenum`, which should make using `generic-array`
less annoying.
  • Loading branch information
tarcieri committed May 23, 2020
1 parent a3c342d commit 371db89
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
8 changes: 5 additions & 3 deletions aead/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ extern crate alloc;
#[cfg(feature = "std")]
extern crate std;

pub use generic_array;
pub use generic_array::{self, typenum::consts};

#[cfg(feature = "heapless")]
pub use heapless;

#[cfg(feature = "alloc")]
use alloc::vec::Vec;
use core::fmt;
use generic_array::{typenum::Unsigned, ArrayLength, GenericArray};

#[cfg(feature = "alloc")]
use alloc::vec::Vec;

/// Error type
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Error;
Expand Down
2 changes: 1 addition & 1 deletion block-cipher-trait/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub mod dev;
mod errors;

pub use crate::errors::InvalidKeyLength;
pub use generic_array;
pub use generic_array::{self, typenum::consts};

use generic_array::typenum::Unsigned;
use generic_array::{ArrayLength, GenericArray};
Expand Down
2 changes: 1 addition & 1 deletion crypto-mac/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod dev;
mod errors;

pub use crate::errors::{InvalidKeyLength, MacError};
pub use generic_array;
pub use generic_array::{self, typenum::consts};

use generic_array::typenum::Unsigned;
use generic_array::{ArrayLength, GenericArray};
Expand Down
2 changes: 1 addition & 1 deletion digest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mod errors;

pub use crate::digest::{Digest, Output};
pub use crate::errors::InvalidOutputSize;
pub use generic_array;
pub use generic_array::{self, typenum::consts};

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
Expand Down
2 changes: 1 addition & 1 deletion stream-cipher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub mod dev;
mod errors;

pub use crate::errors::{InvalidKeyNonceLength, LoopError};
pub use generic_array;
pub use generic_array::{self, typenum::consts};

use generic_array::typenum::Unsigned;
use generic_array::{ArrayLength, GenericArray};
Expand Down
3 changes: 2 additions & 1 deletion universal-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#[cfg(feature = "std")]
extern crate std;

pub use generic_array;
pub use generic_array::{self, typenum::consts};

use generic_array::typenum::Unsigned;
use generic_array::{ArrayLength, GenericArray};
Expand All @@ -32,6 +32,7 @@ use subtle::{Choice, ConstantTimeEq};
pub trait UniversalHash: Clone {
/// Size of the key for the universal hash function
type KeySize: ArrayLength<u8>;

/// Size of the inputs to and outputs from the universal hash function
type BlockSize: ArrayLength<u8>;

Expand Down

0 comments on commit 371db89

Please sign in to comment.