pub struct Resource {
pub resource_type: ResourceType,
pub filename: Option<String>,
pub mime_type: Option<String>,
pub data: Vec<u8>,
pub size: usize,
pub width: Option<u32>,
pub height: Option<u32>,
pub alt_text: Option<String>,
}Expand description
A binary resource (image, media file, etc.).
Fields§
§resource_type: ResourceTypeResource type
filename: Option<String>Original filename (if known)
mime_type: Option<String>MIME type
data: Vec<u8>Binary data
size: usizeSize in bytes
width: Option<u32>Width in pixels (for images)
height: Option<u32>Height in pixels (for images)
alt_text: Option<String>Alt text / description
Implementations§
Source§impl Resource
impl Resource
Sourcepub fn new(resource_type: ResourceType, data: Vec<u8>) -> Self
pub fn new(resource_type: ResourceType, data: Vec<u8>) -> Self
Create a new resource.
Sourcepub fn mime_from_filename(filename: &str) -> Option<String>
pub fn mime_from_filename(filename: &str) -> Option<String>
Determine MIME type from filename.
Sourcepub fn suggested_filename(&self, id: &str) -> String
pub fn suggested_filename(&self, id: &str) -> String
Generate a suggested filename for this resource.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Resource
impl<'de> Deserialize<'de> for Resource
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
Auto Trait Implementations§
impl Freeze for Resource
impl RefUnwindSafe for Resource
impl Send for Resource
impl Sync for Resource
impl Unpin for Resource
impl UnsafeUnpin for Resource
impl UnwindSafe for Resource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more