Struct FieldName

Source
pub struct FieldName(pub Cow<'static, str>);
Expand description

Represents the field level context for validation functions. Its value is the name of the field to be validated.

Tuple Fields§

§0: Cow<'static, str>

Implementations§

Source§

impl FieldName

Source

pub fn unwrap(self) -> Cow<'static, str>

Unwraps this field name context and returns the field name itself

Methods from Deref<Target = Cow<'static, str>>§

Source

pub fn is_borrowed(&self) -> bool

🔬This is a nightly-only experimental API. (cow_is_borrowed)

Returns true if the data is borrowed, i.e. if to_mut would require additional work.

§Examples
#![feature(cow_is_borrowed)]
use std::borrow::Cow;

let cow = Cow::Borrowed("moo");
assert!(cow.is_borrowed());

let bull: Cow<'_, str> = Cow::Owned("...moo?".to_string());
assert!(!bull.is_borrowed());
Source

pub fn is_owned(&self) -> bool

🔬This is a nightly-only experimental API. (cow_is_borrowed)

Returns true if the data is owned, i.e. if to_mut would be a no-op.

§Examples
#![feature(cow_is_borrowed)]
use std::borrow::Cow;

let cow: Cow<'_, str> = Cow::Owned("moo".to_string());
assert!(cow.is_owned());

let bull = Cow::Borrowed("...moo?");
assert!(!bull.is_owned());

Trait Implementations§

Source§

impl Clone for FieldName

Source§

fn clone(&self) -> FieldName

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FieldName

Source§

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

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

impl Deref for FieldName

Source§

type Target = Cow<'static, str>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<A> From<A> for FieldName
where A: Into<Cow<'static, str>>,

Source§

fn from(value: A) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for FieldName

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Validate<AssertFalse, FieldName> for T
where T: HasCheckedValue,

Source§

fn validate( self, name: impl Into<FieldName>, _constraint: &AssertFalse, ) -> Validation<AssertFalse, Self>

Validates this value for being compliant to the specified constraint C in the given context S.
Source§

impl<T> Validate<AssertTrue, FieldName> for T
where T: HasCheckedValue,

Source§

fn validate( self, name: impl Into<FieldName>, _constraint: &AssertTrue, ) -> Validation<AssertTrue, Self>

Validates this value for being compliant to the specified constraint C in the given context S.
Source§

impl<T> Validate<Bound<T>, FieldName> for T
where T: PartialOrd + Clone + Into<Value>,

Source§

fn validate( self, name: impl Into<FieldName>, constraint: &Bound<T>, ) -> Validation<Bound<T>, Self>

Validates this value for being compliant to the specified constraint C in the given context S.
Source§

impl<T> Validate<CharCount, FieldName> for T
where T: HasCharCount,

Source§

fn validate( self, name: impl Into<FieldName>, constraint: &CharCount, ) -> Validation<CharCount, Self>

Validates this value for being compliant to the specified constraint C in the given context S.
Source§

impl<'a, T, A> Validate<Contains<'a, A>, FieldName> for T
where T: HasMember<A> + Into<Value>, A: Clone + Into<Value>,

Source§

fn validate( self, name: impl Into<FieldName>, constraint: &Contains<'a, A>, ) -> Validation<Contains<'a, A>, Self>

Validates this value for being compliant to the specified constraint C in the given context S.
Source§

impl<T> Validate<Digits, FieldName> for T

Source§

fn validate( self, name: impl Into<FieldName>, constraint: &Digits, ) -> Validation<Digits, Self>

Validates this value for being compliant to the specified constraint C in the given context S.
Source§

impl<T> Validate<Length, FieldName> for T
where T: HasLength,

Source§

fn validate( self, name: impl Into<FieldName>, constraint: &Length, ) -> Validation<Length, Self>

Validates this value for being compliant to the specified constraint C in the given context S.
Source§

impl<T> Validate<NonZero, FieldName> for T
where T: HasZeroValue + Into<Value>,

Source§

fn validate( self, name: impl Into<FieldName>, _constraint: &NonZero, ) -> Validation<NonZero, Self>

Validates this value for being compliant to the specified constraint C in the given context S.
Source§

impl<T> Validate<NotEmpty, FieldName> for T
where T: HasEmptyValue,

Source§

fn validate( self, name: impl Into<FieldName>, _constraint: &NotEmpty, ) -> Validation<NotEmpty, Self>

Validates this value for being compliant to the specified constraint C in the given context S.
Source§

impl Validate<Pattern, FieldName> for String

Source§

fn validate( self, name: impl Into<FieldName>, constraint: &Pattern, ) -> Validation<Pattern, Self>

Validates this value for being compliant to the specified constraint C in the given context S.
Source§

impl Eq for FieldName

Source§

impl StructuralPartialEq for FieldName

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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 = 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.