Skip to main content

Valid

Trait Valid 

Source
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§

Source

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§

Source

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§

Source

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

Source§

impl Valid for i8

Source§

const TRIVIAL_CHECK: bool = true

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( _batch: impl Iterator<Item = &'a Self>, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl Valid for i16

Source§

const TRIVIAL_CHECK: bool = true

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( _batch: impl Iterator<Item = &'a Self>, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl Valid for i32

Source§

const TRIVIAL_CHECK: bool = true

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( _batch: impl Iterator<Item = &'a Self>, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl Valid for i64

Source§

const TRIVIAL_CHECK: bool = true

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( _batch: impl Iterator<Item = &'a Self>, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl Valid for isize

Source§

const TRIVIAL_CHECK: bool = true

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( _batch: impl Iterator<Item = &'a Self>, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl Valid for u8

Source§

const TRIVIAL_CHECK: bool = true

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( _batch: impl Iterator<Item = &'a Self>, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl Valid for u16

Source§

const TRIVIAL_CHECK: bool = true

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( _batch: impl Iterator<Item = &'a Self>, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl Valid for u32

Source§

const TRIVIAL_CHECK: bool = true

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( _batch: impl Iterator<Item = &'a Self>, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl Valid for u64

Source§

const TRIVIAL_CHECK: bool = true

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( _batch: impl Iterator<Item = &'a Self>, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl Valid for ()

Source§

const TRIVIAL_CHECK: bool = true

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( _: impl Iterator<Item = &'a Self> + Send, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl Valid for usize

Source§

const TRIVIAL_CHECK: bool = true

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( _batch: impl Iterator<Item = &'a Self>, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl Valid for String

Source§

impl Valid for BigUint

Source§

const TRIVIAL_CHECK: bool = true

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( _batch: impl Iterator<Item = &'a Self>, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl<A> Valid for (A,)
where A: Valid,

Source§

const TRIVIAL_CHECK: bool = <A as Valid>::TRIVIAL_CHECK

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

impl<A, B> Valid for (A, B)
where A: Valid, B: Valid,

Source§

impl<A, B, C> Valid for (A, B, C)
where A: Valid, B: Valid, C: Valid,

Source§

impl<A, B, C, D> Valid for (A, B, C, D)
where A: Valid, B: Valid, C: Valid, D: Valid,

Source§

impl<A, B, C, D, E> Valid for (A, B, C, D, E)
where A: Valid, B: Valid, C: Valid, D: Valid, E: Valid,

Source§

impl<K: Valid, V: Valid> Valid for BTreeMap<K, V>

Source§

const TRIVIAL_CHECK: bool

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( batch: impl Iterator<Item = &'a Self>, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl<T> Valid for Cow<'_, T>

Source§

const TRIVIAL_CHECK: bool = <<T as ToOwned>::Owned>::TRIVIAL_CHECK

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( batch: impl Iterator<Item = &'a Self> + Send, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl<T: Sync> Valid for PhantomData<T>

Source§

const TRIVIAL_CHECK: bool = true

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( _: impl Iterator<Item = &'a Self> + Send, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl<T: Valid> Valid for Option<T>

Source§

const TRIVIAL_CHECK: bool = T::TRIVIAL_CHECK

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( batch: impl Iterator<Item = &'a Self> + Send, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl<T: Valid> Valid for Box<[T]>

Source§

const TRIVIAL_CHECK: bool = T::TRIVIAL_CHECK

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( batch: impl Iterator<Item = &'a Self> + Send, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl<T: Valid> Valid for BTreeSet<T>

Source§

const TRIVIAL_CHECK: bool = T::TRIVIAL_CHECK

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( batch: impl Iterator<Item = &'a Self> + Send, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl<T: Valid> Valid for LinkedList<T>

Source§

const TRIVIAL_CHECK: bool = T::TRIVIAL_CHECK

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( batch: impl Iterator<Item = &'a Self> + Send, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl<T: Valid> Valid for VecDeque<T>

Source§

const TRIVIAL_CHECK: bool = T::TRIVIAL_CHECK

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( batch: impl Iterator<Item = &'a Self> + Send, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl<T: Valid> Valid for Vec<T>

Source§

const TRIVIAL_CHECK: bool = T::TRIVIAL_CHECK

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

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]

Source§

const TRIVIAL_CHECK: bool = T::TRIVIAL_CHECK

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

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.
Source§

const TRIVIAL_CHECK: bool = T::TRIVIAL_CHECK

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( batch: impl Iterator<Item = &'a Self> + Send, ) -> Result<(), SerializationError>
where Self: 'a,

Implementors§