Skip to main content

IntoArg

Trait IntoArg 

Source
pub trait IntoArg {
    // Required method
    fn into_arg(self) -> ArgValue;
}
Expand description

A value a tr! argument converts from, by its type: a number, a string, a date, a path, or an application’s own type.

tr!("id", name = value) converts value by the first of these its type allows:

  1. IntoArg — the typed conversion, below;
  2. a From<T> for ArgValue of the application’s own, as 1.x’s tr! converted every argument (and generic code bounded on it);
  3. Display — any other type with a text is an argument as that text, made when the description is built: an io::Error, an Ipv4Addr, a key binding. The text is not translated; for a word that needs one, pass a string and select on it in the message (.match $state);
  4. none of these — a compile error at the argument, in this trait’s words.
TypeIs
i8 … i128, u8 … u128, isize, usize, and their NonZero formsan integer, exactly: past i64, the exact decimal
f32, f64a floating-point number
boolthe string true or false, which .match selects on
char, &str, String, Arc<str>, Texta string: an Arc<str> is shared as it is, other text is copied once into a shared string (a literal is kept as it is)
Cow<'static, str>a string; borrowed text stays borrowed
&Path, PathBuf, &OsStr, OsString (with std: host-std, native or a Leptos mode)its text, lossy where it is not UTF-8
SystemTime (with std)an instant, to the millisecond; nothing past the years a date can hold
jiff’s Timestamp, Zoned, civil::Date, civil::DateTime (with native)a date: an instant, an instant with its zone, or a floating date and time
DateTimeValue, the runtime’s DateTimea date and time
ArgValueitself: an exact decimal, a value read at format time, …
Arc<C> for a CustomValuean application value a function reads
a signal of any of these (with a Leptos mode)its value, read when the message is formatted
&T for any of these that is Copywhat T is

&String, &PathBuf, &OsString and jiff’s &Zoned are arguments too, through From<&T> for ArgValue: a reference to a type that is not Copy cannot also be an IntoArg beside the &T rule. A Cow that borrows for less than 'static is refused by the borrow checker (the impl is for 'static text, which it keeps): pass &*cow, or the Cow owned.

An application implements it for a type that is a number, a date or a value a custom function reads, which its Display text would not be:

use mf2::{ArgValue, IntoArg};

struct Celsius(f64);

impl IntoArg for Celsius {
    fn into_arg(self) -> ArgValue {
        self.0.into_arg()
    }
}

Required Methods§

Source

fn into_arg(self) -> ArgValue

The argument’s value.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl IntoArg for &OsStr

Available on crate feature host-std, or crate feature native, or (crate features csr or hydrate or ssr) and (crate features leptos-0-8 or leptos) only.
Source§

impl IntoArg for &Path

Available on crate feature host-std, or crate feature native, or (crate features csr or hydrate or ssr) and (crate features leptos-0-8 or leptos) only.
Source§

impl IntoArg for &str

Source§

impl IntoArg for Arc<str>

Source§

impl IntoArg for Cow<'static, str>

Borrowed text stays borrowed, and owned text is shared.

Source§

impl IntoArg for Date

Available on crate feature native only.

A floating date, at 00:00 (a date literal’s time).

Source§

impl IntoArg for DateTime

Available on crate feature native only.

A floating date and time: no offset, so the formatting time zone applies.

Source§

impl IntoArg for NonZero<i8>

Source§

impl IntoArg for NonZero<i16>

Source§

impl IntoArg for NonZero<i32>

Source§

impl IntoArg for NonZero<i64>

Source§

impl IntoArg for NonZero<i128>

Source§

impl IntoArg for NonZero<isize>

Source§

impl IntoArg for NonZero<u8>

Source§

impl IntoArg for NonZero<u16>

Source§

impl IntoArg for NonZero<u32>

Source§

impl IntoArg for NonZero<u64>

Source§

impl IntoArg for NonZero<u128>

Source§

impl IntoArg for NonZero<usize>

Source§

impl IntoArg for OsString

Available on crate feature host-std, or crate feature native, or (crate features csr or hydrate or ssr) and (crate features leptos-0-8 or leptos) only.
Source§

impl IntoArg for PathBuf

Available on crate feature host-std, or crate feature native, or (crate features csr or hydrate or ssr) and (crate features leptos-0-8 or leptos) only.
Source§

impl IntoArg for String

Source§

impl IntoArg for SystemTime

Available on crate feature host-std, or crate feature native, or (crate features csr or hydrate or ssr) and (crate features leptos-0-8 or leptos) only.

The instant, to the millisecond (floored, as a date/time value holds milliseconds); nothing (ArgValue::Unset) past the years a date can hold.

Source§

impl IntoArg for Timestamp

Available on crate feature native only.

The instant, in UTC, to the millisecond (floored).

Source§

impl IntoArg for Zoned

Available on crate feature native only.

The instant at its offset, in its IANA zone when it has one, so that timeZone=input shows it there.

Source§

impl IntoArg for bool

The string true or false, as MF2 has no boolean: .match $flag selects on it, and no allocation is made.

Source§

impl IntoArg for char

Source§

impl IntoArg for f32

Source§

impl IntoArg for f64

Source§

impl IntoArg for i8

Source§

impl IntoArg for i16

Source§

impl IntoArg for i32

Source§

impl IntoArg for i64

Source§

impl IntoArg for i128

Source§

impl IntoArg for isize

Source§

impl IntoArg for u8

Source§

impl IntoArg for u16

Source§

impl IntoArg for u32

Source§

impl IntoArg for u64

An integer that may not fit i64: exact either way. These five are out of line, and share one decimal writer: inline, the branch and the call went into every usize argument of a terminal UI (C1’s record).

Source§

impl IntoArg for u128

Source§

impl IntoArg for usize

Without saturating, where ArgValue::from (1.x) does: a usize past i64::MAX is its exact decimal. On a 32-bit target (the browser’s) every usize fits, and nothing else is compiled.

Source§

impl<C: CustomValue + Send + Sync + 'static> IntoArg for Arc<C>

Source§

impl<T: IntoArg + Copy> IntoArg for &T

A reference to a Copy argument is what the value is: &count.

Source§

impl<T> IntoArg for ArcMemo<T>
where T: IntoArg + Clone + Send + Sync + 'static,

Available on crate features csr or hydrate or ssr only.
Source§

impl<T> IntoArg for ArcReadSignal<T>
where T: IntoArg + Clone + Send + Sync + 'static,

Available on crate features csr or hydrate or ssr only.
Source§

impl<T> IntoArg for ArcRwSignal<T>
where T: IntoArg + Clone + Send + Sync + 'static,

Available on crate features csr or hydrate or ssr only.
Source§

impl<T> IntoArg for ArcSignal<T>
where T: IntoArg + Clone + Send + Sync + 'static,

Available on crate features csr or hydrate or ssr only.
Source§

impl<T> IntoArg for Memo<T>
where T: IntoArg + Clone + Send + Sync + 'static,

Available on crate features csr or hydrate or ssr only.
Source§

impl<T> IntoArg for ReadSignal<T>
where T: IntoArg + Clone + Send + Sync + 'static,

Available on crate features csr or hydrate or ssr only.
Source§

impl<T> IntoArg for RwSignal<T>
where T: IntoArg + Clone + Send + Sync + 'static,

Available on crate features csr or hydrate or ssr only.
Source§

impl<T> IntoArg for Signal<T>
where T: IntoArg + Clone + Send + Sync + 'static,

Available on crate features csr or hydrate or ssr only.

Implementors§