#[non_exhaustive]#[repr(u32)]pub enum FitMode {
Stretch = 0,
Letterbox = 1,
}Expand description
How a source is fit into the destination, without the letterbox pad
colour. The code is the one the C EF_FIT_* enumerators and the
Python Fit enum use.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Stretch = 0
Scale each axis independently to fill the destination (the default).
Letterbox = 1
Keep the source aspect ratio and pad the rest.
Implementations§
Source§impl FitMode
impl FitMode
Sourcepub const fn code(self) -> u32
pub const fn code(self) -> u32
The shared code for this variant. Identical on every surface.
const, deliberately: a downstream binding that cannot
write Variant = OtherEnum::Variant.code() in a #[pyclass]
discriminant position (PyO3 requires a literal there) can
still pin that literal to this value with a
const _: () = assert!(...) – a build-time check instead
of a hand-synced comment. See PyTensorMemory/PyPixelFormat
in crates/python-common/src/tensor.rs for the consumer.
Sourcepub fn from_code(code: u32) -> Option<FitMode>
pub fn from_code(code: u32) -> Option<FitMode>
Reject an unknown code rather than guessing at one.
Sourcepub fn from_str_code(s: &str) -> Option<FitMode>
pub fn from_str_code(s: &str) -> Option<FitMode>
Reject an unknown string rather than guessing at one.
Trait Implementations§
impl Copy for FitMode
Source§impl<'de> Deserialize<'de> for FitMode
impl<'de> Deserialize<'de> for FitMode
Source§fn deserialize<D>(d: D) -> Result<FitMode, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<FitMode, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
impl Eq for FitMode
Source§impl Serialize for FitMode
impl Serialize for FitMode
Source§fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl StructuralPartialEq for FitMode
Auto Trait Implementations§
impl Freeze for FitMode
impl RefUnwindSafe for FitMode
impl Send for FitMode
impl Sync for FitMode
impl Unpin for FitMode
impl UnsafeUnpin for FitMode
impl UnwindSafe for FitMode
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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<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> ⓘ
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