Skip to main content

Conversion

Enum Conversion 

Source
pub enum Conversion {
    Default,
    Infallible(Path),
    Fallible(FallibleConversion),
}
Expand description

How one side of a conversion is performed.

THREE states rather than a path beside a fallible flag, so from-xor-try_from cannot be represented at all: a declaration that wrote both has no model to land in, and the refusal is a parse-time report rather than a rule some later pass has to remember to check.

§The verb rule

from BUILDS this projection; into LEAVES it. Relative to the projection the block is about, never to the domain — one rule across every family, rather than one convention per family:

declarationdirectionwhen
<db>(from | try_from)domain → rowa write
<db>(into | try_into)row → domaina read
graphql(input(into | try_into))input → domain
graphql(output(from | try_from))domain → output

It matches the emitted impls literally: impl From<VideoTrack> for VideoTrackPostgres IS “the row from the domain”, so the declaration that fills it is the row’s from.

Variants§

§

Default

Nothing was declared: move the value, or Into::into it when the stored type differs.

§

Infallible(Path)

from = "…" / into = "…" — a function that cannot fail.

§

Fallible(FallibleConversion)

try_from = "…" / try_into = "…" — a function returning a Result.

Implementations§

Source§

impl Conversion

Source

pub const fn fallible(&self) -> bool

Whether this conversion can fail — the one bit that decides From or TryFrom.

Source

pub const fn declared(&self) -> bool

Whether the declaration named a function for this side.

Trait Implementations§

Source§

impl Clone for Conversion

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Conversion

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Conversion

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Conversion

Source§

impl PartialEq for Conversion

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Conversion

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.