enum ImageDecoderSource {
Data(Vec<u8>),
File(File),
}Expand description
The source for decoding an image.
Variants§
Data(Vec<u8>)
The bytes containing the encoded image.
File(File)
The file containing the encoded image.
Implementations§
Source§impl ImageDecoderSource
impl ImageDecoderSource
Sourceconst MAX_DATA_SIZE: usize = 1_048_576
const MAX_DATA_SIZE: usize = 1_048_576
The maximum size of the Data variant. This is 1 MB.
Sourceasync fn with_bytes(bytes: Vec<u8>) -> Result<Self, MediaFileError>
async fn with_bytes(bytes: Vec<u8>) -> Result<Self, MediaFileError>
Construct an ImageSource from the given bytes.
If the size of the bytes are too big to be kept in memory, they are written to a temporary file.
Sourcefn into_loader(self) -> (Loader, Option<File>)
fn into_loader(self) -> (Loader, Option<File>)
Convert this image source into a loader.
Returns the created loader, and the image file, if any.
Sourceasync fn decode_image(
self,
request_dimensions: Option<FrameDimensions>,
) -> Result<Image, ImageError>
async fn decode_image( self, request_dimensions: Option<FrameDimensions>, ) -> Result<Image, ImageError>
Decode this image source into an Image.
Set request_dimensions if the image will be shown at specific
dimensions. To show the image at its natural size, set it to None.
Trait Implementations§
Source§impl From<File> for ImageDecoderSource
impl From<File> for ImageDecoderSource
Auto Trait Implementations§
impl Freeze for ImageDecoderSource
impl RefUnwindSafe for ImageDecoderSource
impl Send for ImageDecoderSource
impl Sync for ImageDecoderSource
impl Unpin for ImageDecoderSource
impl UnsafeUnpin for ImageDecoderSource
impl UnwindSafe for ImageDecoderSource
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, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more