pub struct VldInt<S> { /* private fields */ }Expand description
A validated integer column type.
Wraps an i64 and ensures it passes the vld schema S on construction.
Implements SQLx Type, Encode, Decode for any database where i64 does.
The schema must have a field named value.
§Example
use vld::prelude::*;
vld::schema! {
#[derive(Debug)]
pub struct AgeField {
pub value: i64 => vld::number().int().min(0).max(150),
}
}
let age = vld_sqlx::VldInt::<AgeField>::new(25).unwrap();
assert_eq!(*age, 25);
assert!(vld_sqlx::VldInt::<AgeField>::new(-1).is_err());Implementations§
Trait Implementations§
Source§impl<'de, S: VldParse> Deserialize<'de> for VldInt<S>
impl<'de, S: VldParse> Deserialize<'de> for VldInt<S>
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'q, S, DB: Database> Encode<'q, DB> for VldInt<S>
impl<'q, S, DB: Database> Encode<'q, DB> for VldInt<S>
Source§fn encode_by_ref(
&self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, BoxDynError>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, BoxDynError>
Source§fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Send + Sync>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Send + Sync>>where
Self: Sized,
Writes the value of
self into buf in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
Source§impl<S> Ord for VldInt<S>
impl<S> Ord for VldInt<S>
Source§impl<S> PartialOrd for VldInt<S>
impl<S> PartialOrd for VldInt<S>
impl<S> Copy for VldInt<S>
impl<S> Eq for VldInt<S>
Auto Trait Implementations§
impl<S> Freeze for VldInt<S>
impl<S> RefUnwindSafe for VldInt<S>where
S: RefUnwindSafe,
impl<S> Send for VldInt<S>where
S: Send,
impl<S> Sync for VldInt<S>where
S: Sync,
impl<S> Unpin for VldInt<S>where
S: Unpin,
impl<S> UnsafeUnpin for VldInt<S>
impl<S> UnwindSafe for VldInt<S>where
S: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more