Skip to main content

CollectionItem

Struct CollectionItem 

Source
pub struct CollectionItem {
    pub iv: u32,
    pub ciphertext_and_tag: Vec<u8>,
}
Expand description

Collection item containing an encrypted payload with its IV

Each item uses a unique counter-based IV derived from the collection’s IV counter. The ciphertext_and_tag contains the AES-GCM encrypted data with the authentication tag appended.

Fields§

§iv: u32

24-bit IV counter value (1 to MAX_IV) This is used to reconstruct the 12-byte GCM nonce: [9 zeros][3-byte IV]

§ciphertext_and_tag: Vec<u8>

Ciphertext with authentication tag appended Format: [encrypted_data][auth_tag] Tag size depends on the symmetric cipher config in the collection manifest

Implementations§

Source§

impl CollectionItem

Source

pub fn new(iv: u32, ciphertext_and_tag: Vec<u8>) -> Self

Create a new collection item

Source

pub fn to_bytes(&self) -> Vec<u8> ⓘ

Container framing: [IV (3B)][ciphertext][tag]

Use this format when the container (FLV/RTMP) provides the length. This is the minimal wire format for streaming scenarios.

Source

pub fn to_nanotdf_payload_bytes(&self) -> Vec<u8> ⓘ

NanoTDF payload framing: [length (3B)][IV (3B)][ciphertext][tag]

This is spec-compliant format with a 3-byte length prefix. Use this when you need a self-describing payload format.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self>

Parse from container framing: [IV (3B)][ciphertext][tag]

The caller must know the total length from the container.

Source

pub fn from_nanotdf_payload_bytes(bytes: &[u8]) -> Result<Self>

Parse from NanoTDF payload framing: [length (3B)][IV (3B)][ciphertext][tag]

Reads the length prefix and validates the payload size.

Source

pub fn read_from<R: Read>(reader: &mut R, total_len: usize) -> Result<Self>

Read from a reader using container framing

Reads exactly total_len bytes (IV + ciphertext + tag).

Source

pub fn read_nanotdf_payload_from<R: Read>(reader: &mut R) -> Result<Self>

Read from a reader using NanoTDF payload framing

Reads the length prefix first, then the payload.

Source

pub fn write_to<W: Write>(&self, writer: &mut W) -> Result<()>

Write to a writer using container framing

Source

pub fn write_nanotdf_payload_to<W: Write>(&self, writer: &mut W) -> Result<()>

Write to a writer using NanoTDF payload framing

Source

pub fn container_size(&self) -> usize

Get the total size in container framing format

Source

pub fn nanotdf_payload_size(&self) -> usize

Get the total size in NanoTDF payload framing format

Source

pub fn iv_bytes(&self) -> [u8; 3]

Convert the IV counter to a 3-byte array

Source

pub fn to_gcm_nonce(&self) -> [u8; 12]

Convert the IV to a 12-byte GCM nonce

Per NanoTDF spec and JS SDK interop: [9 zero bytes][3-byte IV counter]

Trait Implementations§

Source§

impl Clone for CollectionItem

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CollectionItem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CollectionItem

Source§

impl PartialEq for CollectionItem

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CollectionItem

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.