pub trait Valid: Sync {
const TRIVIAL_CHECK: bool = false;
// Required method
fn check(&self) -> Result<(), SerializationError>;
// Provided method
fn batch_check<'a>(
batch: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>
where Self: 'a { ... }
}Provided Associated Constants§
Sourceconst TRIVIAL_CHECK: bool = false
const TRIVIAL_CHECK: bool = false
Whether the check method is trivial (i.e. always returns Ok(())). If this is true,
the batch_check method will skip all checks and return Ok(()).
This should be set to true for types where check is trivial, e.g.
integers, field elements, etc.
This is false by default.
This is primarily an optimization to skip unnecessary checks in batch_check.
Required Methods§
Sourcefn check(&self) -> Result<(), SerializationError>
fn check(&self) -> Result<(), SerializationError>
Checks whether self is valid. If self is valid, returns Ok(()). Otherwise, returns
an error describing the failure.
This method is called by deserialize_with_mode if validate is Validate::Yes.
Provided Methods§
Sourcefn batch_check<'a>(
batch: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>where
Self: 'a,
fn batch_check<'a>(
batch: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>where
Self: 'a,
Checks whether all items in batch are valid. If all items are valid, returns Ok(()).
Otherwise, returns an error describing the first failure.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl Valid for bool
impl Valid for bool
const TRIVIAL_CHECK: Self = true
fn check(&self) -> Result<(), SerializationError>
Source§impl Valid for i8
impl Valid for i8
const TRIVIAL_CHECK: bool = true
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
_batch: impl Iterator<Item = &'a Self>,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl Valid for i16
impl Valid for i16
const TRIVIAL_CHECK: bool = true
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
_batch: impl Iterator<Item = &'a Self>,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl Valid for i32
impl Valid for i32
const TRIVIAL_CHECK: bool = true
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
_batch: impl Iterator<Item = &'a Self>,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl Valid for i64
impl Valid for i64
const TRIVIAL_CHECK: bool = true
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
_batch: impl Iterator<Item = &'a Self>,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl Valid for isize
impl Valid for isize
const TRIVIAL_CHECK: bool = true
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
_batch: impl Iterator<Item = &'a Self>,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl Valid for u8
impl Valid for u8
const TRIVIAL_CHECK: bool = true
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
_batch: impl Iterator<Item = &'a Self>,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl Valid for u16
impl Valid for u16
const TRIVIAL_CHECK: bool = true
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
_batch: impl Iterator<Item = &'a Self>,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl Valid for u32
impl Valid for u32
const TRIVIAL_CHECK: bool = true
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
_batch: impl Iterator<Item = &'a Self>,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl Valid for u64
impl Valid for u64
const TRIVIAL_CHECK: bool = true
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
_batch: impl Iterator<Item = &'a Self>,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl Valid for ()
impl Valid for ()
const TRIVIAL_CHECK: bool = true
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
_: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl Valid for usize
impl Valid for usize
const TRIVIAL_CHECK: bool = true
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
_batch: impl Iterator<Item = &'a Self>,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl Valid for BigUint
impl Valid for BigUint
const TRIVIAL_CHECK: bool = true
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
_batch: impl Iterator<Item = &'a Self>,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl<A> Valid for (A,)where
A: Valid,
impl<A> Valid for (A,)where
A: Valid,
const TRIVIAL_CHECK: bool = <A as Valid>::TRIVIAL_CHECK
fn check(&self) -> Result<(), SerializationError>
Source§impl<A, B> Valid for (A, B)
impl<A, B> Valid for (A, B)
const TRIVIAL_CHECK: bool
fn check(&self) -> Result<(), SerializationError>
Source§impl<A, B, C> Valid for (A, B, C)
impl<A, B, C> Valid for (A, B, C)
const TRIVIAL_CHECK: bool
fn check(&self) -> Result<(), SerializationError>
Source§impl<A, B, C, D> Valid for (A, B, C, D)
impl<A, B, C, D> Valid for (A, B, C, D)
const TRIVIAL_CHECK: bool
fn check(&self) -> Result<(), SerializationError>
Source§impl<A, B, C, D, E> Valid for (A, B, C, D, E)
impl<A, B, C, D, E> Valid for (A, B, C, D, E)
const TRIVIAL_CHECK: bool
fn check(&self) -> Result<(), SerializationError>
Source§impl<K: Valid, V: Valid> Valid for BTreeMap<K, V>
impl<K: Valid, V: Valid> Valid for BTreeMap<K, V>
const TRIVIAL_CHECK: bool
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
batch: impl Iterator<Item = &'a Self>,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl<T> Valid for Cow<'_, T>
impl<T> Valid for Cow<'_, T>
const TRIVIAL_CHECK: bool = <<T as ToOwned>::Owned>::TRIVIAL_CHECK
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
batch: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl<T: Sync> Valid for PhantomData<T>
impl<T: Sync> Valid for PhantomData<T>
const TRIVIAL_CHECK: bool = true
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
_: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl<T: Valid> Valid for Option<T>
impl<T: Valid> Valid for Option<T>
const TRIVIAL_CHECK: bool = T::TRIVIAL_CHECK
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
batch: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl<T: Valid> Valid for Box<[T]>
impl<T: Valid> Valid for Box<[T]>
const TRIVIAL_CHECK: bool = T::TRIVIAL_CHECK
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
batch: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl<T: Valid> Valid for BTreeSet<T>
impl<T: Valid> Valid for BTreeSet<T>
const TRIVIAL_CHECK: bool = T::TRIVIAL_CHECK
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
batch: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl<T: Valid> Valid for LinkedList<T>
impl<T: Valid> Valid for LinkedList<T>
const TRIVIAL_CHECK: bool = T::TRIVIAL_CHECK
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
batch: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl<T: Valid> Valid for VecDeque<T>
impl<T: Valid> Valid for VecDeque<T>
const TRIVIAL_CHECK: bool = T::TRIVIAL_CHECK
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
batch: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl<T: Valid> Valid for Vec<T>
impl<T: Valid> Valid for Vec<T>
const TRIVIAL_CHECK: bool = T::TRIVIAL_CHECK
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
batch: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl<T: Valid, const N: usize> Valid for [T; N]
impl<T: Valid, const N: usize> Valid for [T; N]
const TRIVIAL_CHECK: bool = T::TRIVIAL_CHECK
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
batch: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>where
Self: 'a,
Source§impl<T: ?Sized + Valid + Sync + Send> Valid for Arc<T>
Available on target_has_atomic=ptr only.
impl<T: ?Sized + Valid + Sync + Send> Valid for Arc<T>
target_has_atomic=ptr only.