pub struct Formatted<F: FormatName> { /* private fields */ }Expand description
A string attribute in a declared JSON Schema format.
The wrapper that puts format to work: a resource field typed
Formatted<Email> generates {"type": "string", "format": "email"}, and
the validator asserts it — so a malformed address is a 422 with a
pointer at the member, checked before any of your code runs.
ash_jsonapi::resource! {
User as "user" at "/users",
…
attributes: {
email: Formatted<Email>,
joined: Formatted<Date>,
},
}The inner value is a String; the type parameter only carries which
format to declare. For a format the specification does not define, give
the validator a check with
ValidatorBuilder::format
and write your own FormatName.
Implementations§
Source§impl<F: FormatName> Formatted<F>
impl<F: FormatName> Formatted<F>
Trait Implementations§
Source§impl<F: FormatName> Attribute for Formatted<F>
impl<F: FormatName> Attribute for Formatted<F>
Source§impl<F: FormatName> Clone for Formatted<F>
impl<F: FormatName> Clone for Formatted<F>
Source§impl<F: FormatName> Debug for Formatted<F>
impl<F: FormatName> Debug for Formatted<F>
Source§impl<F: FormatName> Default for Formatted<F>
impl<F: FormatName> Default for Formatted<F>
Source§impl<F: FormatName> Display for Formatted<F>
impl<F: FormatName> Display for Formatted<F>
impl<F: FormatName> Eq for Formatted<F>
Source§impl<F: FormatName> Hash for Formatted<F>
impl<F: FormatName> Hash for Formatted<F>
Source§impl<F: FormatName> Ord for Formatted<F>
impl<F: FormatName> Ord for Formatted<F>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl<F: FormatName> PartialEq for Formatted<F>
impl<F: FormatName> PartialEq for Formatted<F>
Source§impl<F: FormatName> PartialOrd for Formatted<F>
impl<F: FormatName> PartialOrd for Formatted<F>
Auto Trait Implementations§
impl<F> Freeze for Formatted<F>where
PhantomData<F>: Freeze,
impl<F> RefUnwindSafe for Formatted<F>where
PhantomData<F>: RefUnwindSafe,
impl<F> Send for Formatted<F>where
PhantomData<F>: Send,
impl<F> Sync for Formatted<F>where
PhantomData<F>: Sync,
impl<F> Unpin for Formatted<F>where
PhantomData<F>: Unpin,
impl<F> UnsafeUnpin for Formatted<F>where
PhantomData<F>: UnsafeUnpin,
impl<F> UnwindSafe for Formatted<F>where
PhantomData<F>: UnwindSafe,
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
Mutably borrows from an owned value. Read more