pub struct Memory(/* private fields */);Expand description
A memory cost, carried in kibibytes.
The unit is the point of this type. Argon2’s m_cost is a count of 1 KiB
blocks, so a bare 65536 at a call site could be read as bytes, KiB, MiB or
blocks; Memory::mib(64) cannot.
No constructor validates or panics. The value is held as a u64 and checked
once, by ParamsBuilder::build, which is the only place that knows the
target’s MAX_MEMORY.
use argon2_rust::params::Memory;
assert_eq!(Memory::mib(64), Memory::kib(65536));
assert_eq!(Memory::gib(1), Memory::mib(1024));Implementations§
Source§impl Memory
impl Memory
Sourcepub const fn mib(mib: u64) -> Memory
pub const fn mib(mib: u64) -> Memory
A cost in mebibytes.
Saturating, not wrapping: mib(u64::MAX) yields u64::MAX KiB rather
than panicking in a debug build. Any saturated value is far above
MAX_MEMORY and becomes Error::MemoryTooMuch at build().
Sourcepub const fn gib(gib: u64) -> Memory
pub const fn gib(gib: u64) -> Memory
A cost in gibibytes. Saturating, for the reason given on Memory::mib.
Trait Implementations§
impl Copy for Memory
impl Eq for Memory
Source§impl Ord for Memory
impl Ord for Memory
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Memory
impl PartialOrd for Memory
impl StructuralPartialEq for Memory
Auto Trait Implementations§
impl Freeze for Memory
impl RefUnwindSafe for Memory
impl Send for Memory
impl Sync for Memory
impl Unpin for Memory
impl UnsafeUnpin for Memory
impl UnwindSafe for Memory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more