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<Image, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Image, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Image
Source§impl Serialize for Image
impl Serialize for Image
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.