pub struct ValidationBundle<'a, const N: usize> { /* private fields */ }Expand description
A bundle that composes multiple ValidationGroups into a single check.
Run all groups in order. If any group fails, the bundle fails. Useful for instruction handlers that share common preconditions but add instruction-specific checks on top.
ⓘ
let mut bundle = ValidationBundle::<3>::new();
bundle.add_group(&common_checks)?;
bundle.add_group(&transfer_checks)?;
bundle.run(&ctx)?;Implementations§
Source§impl<'a, const N: usize> ValidationBundle<'a, N>
impl<'a, const N: usize> ValidationBundle<'a, N>
Sourcepub const fn new() -> ValidationBundle<'a, N>
pub const fn new() -> ValidationBundle<'a, N>
Create an empty bundle.
Sourcepub fn add(&mut self, v: &'a dyn Validatable) -> Result<(), ProgramError>
pub fn add(&mut self, v: &'a dyn Validatable) -> Result<(), ProgramError>
Add a validatable group or graph to the bundle.
Sourcepub fn run(&self, ctx: &ValidationContext<'_>) -> Result<(), ProgramError>
pub fn run(&self, ctx: &ValidationContext<'_>) -> Result<(), ProgramError>
Run all groups in order. Fail-fast on first error.
Trait Implementations§
Source§impl<'a, const N: usize> Default for ValidationBundle<'a, N>
impl<'a, const N: usize> Default for ValidationBundle<'a, N>
Source§fn default() -> ValidationBundle<'a, N>
fn default() -> ValidationBundle<'a, N>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<'a, const N: usize> Freeze for ValidationBundle<'a, N>
impl<'a, const N: usize> !RefUnwindSafe for ValidationBundle<'a, N>
impl<'a, const N: usize> !Send for ValidationBundle<'a, N>
impl<'a, const N: usize> !Sync for ValidationBundle<'a, N>
impl<'a, const N: usize> Unpin for ValidationBundle<'a, N>
impl<'a, const N: usize> UnsafeUnpin for ValidationBundle<'a, N>
impl<'a, const N: usize> !UnwindSafe for ValidationBundle<'a, N>
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