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§
Sourcefn build_segment_size(&self) -> u32
fn build_segment_size(&self) -> u32
Sourcefn set_segment_size(&mut self, size: u32)
fn set_segment_size(&mut self, size: u32)
Sourcefn build_signature(&self, key: Option<&[u8]>) -> Result<Vec<u8>, Error>
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 aVec<u8>
, or an error.
§Example:
let signature = image.build_signature(&key);