TryPatch

Trait TryPatch 

Source
pub trait TryPatch {
    type Patch: Clone;
    type Error: Error + Send + Sync + 'static;

    // Required method
    fn try_patch(&mut self, patch: Self::Patch) -> Result<(), Self::Error>;
}
Expand description

A fallible variant of Patchable.

This trait allows components to apply a patch with validation and return a custom error when the patch cannot be safely applied.

Required Associated Types§

Source

type Patch: Clone

The type of patch associated with this structure.

Source

type Error: Error + Send + Sync + 'static

The error type returned when applying a patch fails.

Required Methods§

Source

fn try_patch(&mut self, patch: Self::Patch) -> Result<(), Self::Error>

Applies the provided patch to self.

§Errors

Returns an error if the patch is invalid or cannot be applied.

Implementors§

Source§

impl<T: Patchable> TryPatch for T

Blanket implementation for all Patchable types, where patching is infallible.