Struct edjx::FileAttributes
source · pub struct FileAttributes {
pub properties: Option<HashMap<String, String>>,
pub default_version: Option<String>,
}
Expand description
Represents the attributes associated with a stored file.
Fields§
§properties: Option<HashMap<String, String>>
§default_version: Option<String>
Implementations§
source§impl FileAttributes
impl FileAttributes
pub fn new(
properties: Option<HashMap<String, String>>,
default_version: Option<String>
) -> Self
sourcepub fn from_bytes(bytes: Vec<u8>) -> Result<Self, StorageError>
pub fn from_bytes(bytes: Vec<u8>) -> Result<Self, StorageError>
Examples found in repository?
src/storage.rs (line 363)
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
pub fn get_attributes<B, FN>(bucket_id: B, file_name: FN) -> Result<FileAttributes, StorageError>
where
B: AsRef<str>,
FN: AsRef<str>,
{
let bucket_id_str = bucket_id.as_ref();
let file_name_str = file_name.as_ref();
if file_name_str.trim().is_empty() {
return Err(StorageError::MissingFileName);
}
if bucket_id_str.trim().is_empty() {
return Err(StorageError::MissingBucketID);
}
let mut error_code: i32 = 0;
let response_value = unsafe {
host_storage_get_attributes(
bucket_id_str.as_ptr(),
bucket_id_str.len() as u32,
file_name_str.as_ptr(),
file_name_str.len() as u32,
&mut error_code,
)
};
if response_value < 0 {
return Err(StorageError::from(Error::from_i32(error_code).unwrap()));
}
let mut resp = match StorageResponse::new() {
Ok(resp) => resp,
Err(err) => return Err(err),
};
match resp.read_body() {
Ok(body) => FileAttributes::from_bytes(body),
Err(_) => Err(StorageError::InternalError),
}
}
Trait Implementations§
source§impl Clone for FileAttributes
impl Clone for FileAttributes
source§fn clone(&self) -> FileAttributes
fn clone(&self) -> FileAttributes
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for FileAttributes
impl Debug for FileAttributes
source§impl<'de> Deserialize<'de> for FileAttributes
impl<'de> Deserialize<'de> for FileAttributes
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more