pub enum Image {
DataUrl(String),
Inline(InlineImage),
}Expand description
An image: a data: URL string, or {content_type, base64}. Remote URLs
are never accepted.
Variants§
DataUrl(String)
Inline(InlineImage)
Implementations§
Source§impl Image
impl Image
Sourcepub fn approx_bytes(&self) -> usize
pub fn approx_bytes(&self) -> usize
The image’s size in decoded bytes, estimated from its base64 length.
Exact for well-formed base64; Image::decode is the check.
Sourcepub fn decode(&self) -> Result<DecodedImage, String>
pub fn decode(&self) -> Result<DecodedImage, String>
The content type and decoded bytes, or why the image is malformed.
A data: URL must be data:<content type>;base64,<payload>. The
content type is not checked against a format list here.
Sourcepub fn canonical(&self) -> Result<InlineImage, String>
pub fn canonical(&self) -> Result<InlineImage, String>
The canonical form batch identity hashes: the content type and the decoded bytes as standard padded base64.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Image
impl<'de> Deserialize<'de> for Image
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
impl Eq for Image
impl StructuralPartialEq for Image
Auto Trait Implementations§
impl Freeze for Image
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnsafeUnpin for Image
impl UnwindSafe for Image
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