DurationHumanValidator

Struct DurationHumanValidator 

Source
pub struct DurationHumanValidator {
    pub min: DurationHuman,
    pub default: DurationHuman,
    pub max: DurationHuman,
}

Fields§

§min: DurationHuman§default: DurationHuman§max: DurationHuman

Implementations§

Source§

impl DurationHumanValidator

Source

pub const fn new( minimal_nanos: u64, default_nanos: u64, maximal_nanos: u64, ) -> Self

Create a new validator, with the given minimal, default and maximal durations

§Panics

If any value < 1s, or if not: minimal_nanos <= default_nanos <= maximal_nanos

Source

pub fn parse_and_validate( &self, duration: &str, ) -> Result<DurationHuman, DurationError>

To be used as a validate_parser for clap

 validate_parser = {|lifetime: &str|duration_range.parse_and_validate(lifetime)}
§Errors

Will return Err if duration is not within the given range permission to read it.

Source

pub fn contains(&self, duration: &DurationHuman) -> bool

Trait Implementations§

Source§

impl Debug for DurationHumanValidator

Source§

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

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

impl Default for DurationHumanValidator

Source§

fn default() -> DurationHumanValidator

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

impl Display for DurationHumanValidator

Source§

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

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

impl From<&DurationHumanValidator> for (String, String, String)

Source§

fn from(duration: &DurationHumanValidator) -> Self

Converts to this type from the input type.
Source§

impl From<&DurationHumanValidator> for (u64, u64, u64)

Source§

fn from(duration: &DurationHumanValidator) -> Self

Converts to this type from the input type.
Source§

impl Parse for DurationHumanValidator

Source§

fn parse(input: ParseStream<'_>) -> Result<Self>

Source§

impl TryFrom<(&str, &str)> for DurationHumanValidator

Source§

type Error = DurationError

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

fn try_from(value: (&str, &str)) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<(&str, &str, &str)> for DurationHumanValidator

Source§

type Error = DurationError

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

fn try_from(value: (&str, &str, &str)) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<(DurationHuman, DurationHuman)> for DurationHumanValidator

Source§

type Error = DurationError

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

fn try_from(value: (DurationHuman, DurationHuman)) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<(DurationHuman, DurationHuman, DurationHuman)> for DurationHumanValidator

Source§

type Error = DurationError

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

fn try_from( value: (DurationHuman, DurationHuman, DurationHuman), ) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<(u64, u64)> for DurationHumanValidator

Source§

type Error = DurationError

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

fn try_from(value: (u64, u64)) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<(u64, u64, u64)> for DurationHumanValidator

Source§

type Error = DurationError

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

fn try_from(value: (u64, u64, u64)) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Vec<ParsedDuration>> for DurationHumanValidator

Source§

type Error = DurationError

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

fn try_from(value: Vec<ParsedDuration>) -> Result<Self, Self::Error>

Performs the 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.