use std::hash::Hash;
use crate::*;
define_suite!(
HashSuite,
AEGP_HashSuite1,
kAEGPHashSuite,
kAEGPHashSuiteVersion1
);
#[derive(Debug, Clone, Copy)]
#[repr(transparent)]
pub struct Guid(pub ae_sys::AEGP_GUID);
impl Guid {
pub fn new() -> Self { Self(ae_sys::AEGP_GUID { bytes: [0; 4] }) }
pub fn as_mut_ptr(&mut self) -> *mut ae_sys::AEGP_GUID { &mut self.0 }
pub fn as_raw(&self) -> ae_sys::AEGP_GUID { self.0 }
}
impl Default for Guid {
fn default() -> Self { Self::new() }
}
impl From<ae_sys::AEGP_GUID> for Guid {
fn from(guid: ae_sys::AEGP_GUID) -> Self { Self(guid) }
}
impl From<Guid> for ae_sys::AEGP_GUID {
fn from(guid: Guid) -> Self { guid.0 }
}
impl HashSuite {
pub fn new() -> Result<Self, Error> { crate::Suite::new() }
pub fn create_hash_from_ptr(&self, data: &[u8]) -> Result<Guid, Error> {
let mut hash = Guid::new();
call_suite_fn!(
self,
AEGP_CreateHashFromPtr,
data.len() as ae_sys::A_u_longlong,
data.as_ptr() as *const _,
hash.as_mut_ptr()
)?;
Ok(hash)
}
pub fn hash_mix_in_ptr(&self, data: &[u8], hash: &mut Guid) -> Result<(), Error> {
call_suite_fn!(
self,
AEGP_HashMixInPtr,
data.len() as ae_sys::A_u_longlong,
data.as_ptr() as *const _,
hash.as_mut_ptr()
)
}
}