Skip to main content

DependencySpec

Struct DependencySpec 

Source
pub struct DependencySpec { /* private fields */ }
Expand description

Describes one ordered dependency slot supplied to a validator.

§Examples

use qubit_validator::{DependencySpec, InputType};

let dependency = DependencySpec::new("credential", InputType::Text, false);
assert_eq!(dependency.name(), "credential");
assert!(!dependency.optional());

Implementations§

Source§

impl DependencySpec

Source

pub const fn new(name: &'static str, input: InputType, optional: bool) -> Self

Creates a dependency declaration.

§Parameters
  • name: non-empty logical slot name used in diagnostics.
  • input: erased value shape required by the slot.
  • optional: whether an explicit missing value is accepted.
§Returns

Returns a declaration containing the supplied dependency metadata.

§Panics

Panics when name is empty.

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];
More examples
Hide additional examples
examples/local_registry.rs (line 82)
81static DEPENDENCIES: &[DependencySpec] = &[
82    DependencySpec::new("minimum", InputType::Text, false),
83    DependencySpec::new("maximum", InputType::Text, false),
84];
Source

pub const fn name(self) -> &'static str

Returns the logical slot name.

Source

pub const fn input(self) -> InputType

Returns the required input shape.

Source

pub const fn optional(self) -> bool

Returns whether an explicit missing value is accepted.

§Returns

Returns true when the dependency accepts super::ValidationValue::Missing.

Trait Implementations§

Source§

impl Clone for DependencySpec

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 DependencySpec

Source§

impl Debug for DependencySpec

Source§

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

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

impl Eq for DependencySpec

Source§

impl PartialEq for DependencySpec

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 DependencySpec

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.