pub struct Asset {
pub id: String,
pub media_type: String,
pub bytes: Vec<u8>,
pub width_px: Option<u32>,
pub height_px: Option<u32>,
pub dpi: Option<f32>,
}Expand description
An image file found in a manuscript, referenced by Block::Image::asset.
An image file, e.g. assets/image1.png in a project.
Fields§
§id: StringFile name under assets/ in the project, e.g. image1.png.
media_type: String§bytes: Vec<u8>§width_px: Option<u32>Pixel size from the file header, if it could be read.
height_px: Option<u32>§dpi: Option<f32>Resolution stored in the file (PNG pHYs, JPEG JFIF), if any.
Implementations§
Source§impl Asset
impl Asset
Sourcepub fn new(id: impl Into<String>, bytes: Vec<u8>) -> Asset
pub fn new(id: impl Into<String>, bytes: Vec<u8>) -> Asset
An asset with metadata read from bytes. Content that is not a
supported image gets application/octet-stream and no size.
Sourcepub fn is_valid_id(id: &str) -> bool
pub fn is_valid_id(id: &str) -> bool
Whether id can be used as a file name under assets/: a plain
name (no directories, no .., no leading dot) of portable
characters.
Trait Implementations§
impl StructuralPartialEq for Asset
Auto Trait Implementations§
impl Freeze for Asset
impl RefUnwindSafe for Asset
impl Send for Asset
impl Sync for Asset
impl Unpin for Asset
impl UnsafeUnpin for Asset
impl UnwindSafe for Asset
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