Skip to main content

InputType

Enum InputType 

Source
#[non_exhaustive]
pub enum InputType { Text, Typed(TypeId), }
Expand description

The two intentionally small input views used by the validation boundary.

§Examples

use qubit_validator::{InputType, ValidationValue};

assert!(InputType::Text.accepts(ValidationValue::Text("hello")));
assert!(InputType::of::<u32>().accepts(ValidationValue::Typed(&3_u32)));

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Text

A borrowed UTF-8 text view.

§

Typed(TypeId)

A value whose concrete Rust type must match exactly.

Tuple Fields

§0: TypeId

The exact concrete type accepted at the erased boundary.

Implementations§

Source§

impl InputType

Source

pub const fn of<T: 'static>() -> Self

Creates a typed input descriptor for T.

§Type Parameters
  • T: Exact concrete input type; it must be 'static for TypeId.
§Returns

A descriptor that accepts only values whose concrete type is T.

Examples found in repository?
examples/validate_named_bench.rs (line 53)
53static D1: &[DependencySpec] = &[DependencySpec::new("a", InputType::of::<u64>(), false)];
54static D4: &[DependencySpec] = &[
55    DependencySpec::new("a", InputType::of::<u64>(), false),
56    DependencySpec::new("b", InputType::of::<u64>(), false),
57    DependencySpec::new("c", InputType::of::<u64>(), false),
58    DependencySpec::new("d", InputType::of::<u64>(), false),
59];
60static D8: &[DependencySpec] = &[
61    DependencySpec::new("a", InputType::of::<u64>(), false),
62    DependencySpec::new("b", InputType::of::<u64>(), false),
63    DependencySpec::new("c", InputType::of::<u64>(), false),
64    DependencySpec::new("d", InputType::of::<u64>(), false),
65    DependencySpec::new("e", InputType::of::<u64>(), false),
66    DependencySpec::new("f", InputType::of::<u64>(), false),
67    DependencySpec::new("g", InputType::of::<u64>(), false),
68    DependencySpec::new("h", InputType::of::<u64>(), false),
69];
70static D9: &[DependencySpec] = &[
71    DependencySpec::new("a", InputType::of::<u64>(), false),
72    DependencySpec::new("b", InputType::of::<u64>(), false),
73    DependencySpec::new("c", InputType::of::<u64>(), false),
74    DependencySpec::new("d", InputType::of::<u64>(), false),
75    DependencySpec::new("e", InputType::of::<u64>(), false),
76    DependencySpec::new("f", InputType::of::<u64>(), false),
77    DependencySpec::new("g", InputType::of::<u64>(), false),
78    DependencySpec::new("h", InputType::of::<u64>(), false),
79    DependencySpec::new("i", InputType::of::<u64>(), false),
80];
Source

pub fn accepts(self, value: ValidationValue<'_>) -> bool

Returns whether this descriptor accepts the supplied input shape.

§Parameters
  • value: Borrowed input whose shape is compared with this descriptor.
§Returns

Returns true when value has the exact shape described by self.

Trait Implementations§

Source§

impl Clone for InputType

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for InputType

Source§

impl Debug for InputType

Source§

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

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

impl Eq for InputType

Source§

impl PartialEq for InputType

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for InputType

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<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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.