#[non_exhaustive]pub struct ArtifactMetadata {
pub width: Option<u32>,
pub height: Option<u32>,
pub frame_count: u32,
pub duration: Option<Duration>,
pub has_alpha: Option<bool>,
pub orientation: Option<u16>,
}Expand description
Metadata that the Core layer can carry between decode and encode steps.
§Examples
use truss::{ArtifactMetadata, Dimensions};
// The struct is `#[non_exhaustive]`, so start from `default()` and assign; a field
// truss adds later is then a minor change rather than a breaking one.
let mut meta = ArtifactMetadata::default();
meta.width = Some(1920);
meta.height = Some(1080);
assert_eq!(meta.dimensions(), Some(Dimensions::new(1920, 1080)));
assert_eq!(meta.frame_count, 1);
// With no orientation tag, the oriented dimensions are the stored ones.
assert_eq!(meta.oriented_dimensions(), Some(Dimensions::new(1920, 1080)));
// Orientation 6 is a quarter turn, so a transform swaps the axes.
let mut rotated = meta.clone();
rotated.orientation = Some(6);
assert_eq!(rotated.oriented_dimensions(), Some(Dimensions::new(1080, 1920)));
// When either dimension is unknown, dimensions() returns None
let mut partial = ArtifactMetadata::default();
partial.width = Some(100);
assert!(partial.dimensions().is_none());Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.width: Option<u32>The rendered width in pixels, when known.
height: Option<u32>The rendered height in pixels, when known.
frame_count: u32The number of frames contained in the artifact.
duration: Option<Duration>The total animation duration, when known.
has_alpha: Option<bool>Whether the artifact contains alpha, when known.
orientation: Option<u16>The EXIF orientation tag, when the artifact carries one.
width and height are the dimensions as stored in the container. A transform
applies this tag by default, and values 5 to 8 transpose the two, so a caller that
records dimensions at upload time and serves derivatives later needs this to know
which way round the result will be. ArtifactMetadata::oriented_dimensions does
that arithmetic.
Implementations§
Source§impl ArtifactMetadata
impl ArtifactMetadata
Sourcepub fn dimensions(&self) -> Option<Dimensions>
pub fn dimensions(&self) -> Option<Dimensions>
Returns the dimensions as a Dimensions value, if both width and height are known.
Sourcepub fn oriented_dimensions(&self) -> Option<Dimensions>
pub fn oriented_dimensions(&self) -> Option<Dimensions>
Returns the dimensions after the EXIF orientation is applied.
These are the dimensions a transform produces with auto-orientation on, which is the
default. They equal ArtifactMetadata::dimensions whenever there is no orientation
tag or the tag does not transpose the axes, so a caller can read these unconditionally.
Trait Implementations§
Source§impl Clone for ArtifactMetadata
impl Clone for ArtifactMetadata
Source§fn clone(&self) -> ArtifactMetadata
fn clone(&self) -> ArtifactMetadata
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ArtifactMetadata
impl Debug for ArtifactMetadata
Source§impl Default for ArtifactMetadata
impl Default for ArtifactMetadata
impl Eq for ArtifactMetadata
Source§impl PartialEq for ArtifactMetadata
impl PartialEq for ArtifactMetadata
impl StructuralPartialEq for ArtifactMetadata
Auto Trait Implementations§
impl Freeze for ArtifactMetadata
impl RefUnwindSafe for ArtifactMetadata
impl Send for ArtifactMetadata
impl Sync for ArtifactMetadata
impl Unpin for ArtifactMetadata
impl UnsafeUnpin for ArtifactMetadata
impl UnwindSafe for ArtifactMetadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> ⓘ
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> ⓘ
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