amebazii::types::image

Trait AsImage

Source
pub trait AsImage {
    // Required methods
    fn build_segment_size(&self) -> u32;
    fn set_segment_size(&mut self, size: u32);
    fn build_signature(&self, key: Option<&[u8]>) -> Result<Vec<u8>, Error>;
    fn set_signature(&mut self, signature: &[u8]);
}
Expand description

A trait that provides common functionality for image-like objects, such as computing and setting the segment size and signature.

Required Methods§

Source

fn build_segment_size(&self) -> u32

Computes the segment size for the image.

The segment size typically represents the total size of the image segment, including all of its components (e.g., header, records, user data, etc.).

§Returns:
  • u32 representing the segment size.
§Example:
let segment_size = image.build_segment_size();
Source

fn set_segment_size(&mut self, size: u32)

Sets the segment size for the image.

This method allows setting the segment size, typically after calculating it or modifying the image in some way.

§Arguments:
  • size: The new segment size to set.
§Example:
image.set_segment_size(1024);
Source

fn build_signature(&self, key: Option<&[u8]>) -> Result<Vec<u8>, Error>

Computes the signature for the image using the provided key.

The signature is usually a hash or HMAC generated from the image data and a secret key, often used for verification or authentication purposes.

§Arguments:
  • key: The key used to compute the signature.
§Returns:
  • Result<Vec<u8>, crate::error::Error>: The signature as a Vec<u8>, or an error.
§Example:
let signature = image.build_signature(&key);
Source

fn set_signature(&mut self, signature: &[u8])

Sets the signature for the image.

This method allows setting the signature after computing it or for some validation process.

§Arguments:
  • signature: The computed signature to set.
§Example:
image.set_signature(&signature);

Implementors§