Struct ValidityError
pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> { /* private fields */ }
The error emitted if the conversion source contains invalid data.
Implementations
impl<Src, Dst: ?Sized + TryFromBytes> ValidityError<Src, Dst>
fn into_src(self) -> SrcProduces the source underlying the failed conversion.
fn map_src<NewSrc>(self, f: impl FnOnce(Src) -> NewSrc) -> ValidityError<NewSrc, Dst>Maps the source value associated with the conversion error.
This can help mitigate [issues with
Send,Syncand'staticbounds][self#send-sync-and-static].Examples
use zerocopy::*; let source: u8 = 42; // Try to transmute the `source` to a `bool`. This will fail. let maybe_bool: Result<bool, ValidityError<u8, bool>> = try_transmute!(source); // Drop the error's source. let maybe_bool: Result<bool, ValidityError<(), bool>> = maybe_bool.map_err(|err| { err.map_src(drop) });
Trait Implementations
impl<Src, Dst> Display for ValidityError<Src, Dst>
where
Dst: KnownLayout + TryFromBytes + ?Sized,
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<Src, Dst> Error for ValidityError<Src, Dst>
where
Dst: KnownLayout + TryFromBytes + ?Sized,
impl<Src, Dst: ?Sized + TryFromBytes> Debug for ValidityError<Src, Dst>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<Src: Clone, Dst: ?Sized + TryFromBytes> Clone for ValidityError<Src, Dst>
fn clone(&self) -> Self
impl<Src: Eq, Dst: ?Sized + TryFromBytes> Eq for ValidityError<Src, Dst>
impl<Src: PartialEq, Dst: ?Sized + TryFromBytes> PartialEq for ValidityError<Src, Dst>
fn eq(&self, other: &Self) -> bool