pub trait ByteArray<const LENGTH: usize>: Bytes {
// Required method
fn as_array(&self) -> &[u8; LENGTH];
}Expand description
Fixed-length byte array.
Implemented only by fixed-size storage such as [u8; LENGTH],
StackByteArray, and the protected heap arrays, so the length is checked
at compile time. Convert runtime-length input with
StackByteArray::try_from or <[u8; LENGTH]>::try_from, which reject any
length other than LENGTH.
Slices and vectors are not fixed-length byte arrays:
ⓘ
use dryoc::dryocsecretbox::{DryocSecretBox, Nonce};
use dryoc::types::*;
let key = vec![0u8; 32];
let nonce = Nonce::generate();
DryocSecretBox::encrypt_to_vecbox(b"hello", &nonce, &key);ⓘ
use dryoc::dryocsecretbox::{DryocSecretBox, Nonce};
use dryoc::types::*;
let key: &[u8] = &[0u8; 32];
let nonce = Nonce::generate();
DryocSecretBox::encrypt_to_vecbox(b"hello", &nonce, &key);Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Implementors§
impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> ByteArray<CRYPTO_BOX_BEFORENMBYTES> for PrecalcSecretKey<InnerKey>
impl<const LENGTH: usize> ByteArray<LENGTH> for HeapByteArray<LENGTH>
Available on crate feature
protected only.impl<const LENGTH: usize> ByteArray<LENGTH> for Protected<HeapByteArray<LENGTH>, ReadOnly, Locked>
Available on crate feature
protected only.impl<const LENGTH: usize> ByteArray<LENGTH> for Protected<HeapByteArray<LENGTH>, ReadOnly, Unlocked>
Available on crate feature
protected only.impl<const LENGTH: usize> ByteArray<LENGTH> for Protected<HeapByteArray<LENGTH>, ReadWrite, Locked>
Available on crate feature
protected only.impl<const LENGTH: usize> ByteArray<LENGTH> for Protected<HeapByteArray<LENGTH>, ReadWrite, Unlocked>
Available on crate feature
protected only.