- attachment data
Publish / Publish (crates.io) (push) Failing after 3m6s

This commit is contained in:
w.pomp
2026-07-14 09:35:34 +02:00
parent 4ccdb7611c
commit 19cdc9a121
7 changed files with 114 additions and 27 deletions
+13 -2
View File
@@ -463,7 +463,7 @@ impl SubBlock {
///
/// \\returns An error-code indicating success or failure of the operation.
pub fn get_raw_data(&self, tp: RawDataType, size: i32) -> Result<(i32, Vec<u8>), Error> {
let mut data = Vec::<u8>::with_capacity(size as usize);
let mut data = vec![0u8; size as usize];
let size = Box::into_raw(Box::new(size as c_ulong));
lib_czi_error(unsafe {
libCZI_SubBlockGetRawData(**self, tp as c_int, size, data.as_mut_ptr() as *mut c_void)
@@ -510,7 +510,7 @@ impl Attachment {
///
/// \\returns An error-code indicating success or failure of the operation.
pub fn get_raw_data(&self, size: i32) -> Result<(i32, Vec<u8>), Error> {
let mut data = Vec::<u8>::with_capacity(size as usize);
let mut data = vec![0u8; size as usize];
let size = Box::into_raw(Box::new(size as c_ulong));
lib_czi_error(unsafe {
libCZI_AttachmentGetRawData(**self, size, data.as_mut_ptr() as *mut c_void)
@@ -518,6 +518,17 @@ impl Attachment {
Ok((unsafe { *Box::from_raw(size) as i32 }, data))
}
/// convenience method that extracts some types of data
pub fn get_data(&self) -> Result<AttachmentData, Error> {
let (n, _) = self.get_raw_data(0)?;
let (_, data) = self.get_raw_data(n)?;
Ok(match self.get_info()?.get_content_file_type()?.as_str() {
"CZTIMS" | "CZFOC" => AttachmentData::from_float(data.as_slice())?,
"CZEXP" | "CZHWS" | "CZMVM" | "CZFBMX" => AttachmentData::from_xml(data.as_slice())?,
_ => AttachmentData::Unknown(data),
})
}
/// Release the specified attachment object.
///
/// \\param attachment_object The attachment object to be released.