Struct image_texel::MatrixReuseError
source · pub struct MatrixReuseError<P> { /* private fields */ }
Expand description
Error representation for a failed buffer reuse for an image.
Emitted as a result of Matrix::from_buffer
when the buffer capacity is not large enough to
serve as an image of requested layout with causing a reallocation.
It is possible to retrieve the buffer that cause the failure with into_buffer
. This allows one
to manually try to correct the error with additional checks, or implement a fallback strategy
which does not require the interpretation as a full image.
let buffer = TexelBuffer::<u8>::new(16);
let allocation = buffer.as_bytes().as_ptr();
let bad_layout = layout::Matrix::width_and_height(buffer.capacity() + 1, 1).unwrap();
let error = match Matrix::from_reused_buffer(buffer, bad_layout) {
Ok(_) => unreachable!("The layout requires one too many pixels"),
Err(error) => error,
};
// Get back the original buffer.
let buffer = error.into_buffer();
assert_eq!(buffer.as_bytes().as_ptr(), allocation);
Implementations
sourceimpl<P> MatrixReuseError<P>
impl<P> MatrixReuseError<P>
sourcepub fn into_buffer(self) -> TexelBuffer<P>
pub fn into_buffer(self) -> TexelBuffer<P>
Unwrap the original buffer.
Trait Implementations
sourceimpl<P> Debug for MatrixReuseError<P>
impl<P> Debug for MatrixReuseError<P>
sourceimpl<P: PartialEq> PartialEq<MatrixReuseError<P>> for MatrixReuseError<P>
impl<P: PartialEq> PartialEq<MatrixReuseError<P>> for MatrixReuseError<P>
sourcefn eq(&self, other: &MatrixReuseError<P>) -> bool
fn eq(&self, other: &MatrixReuseError<P>) -> bool
impl<P: Eq> Eq for MatrixReuseError<P>
impl<P> StructuralEq for MatrixReuseError<P>
impl<P> StructuralPartialEq for MatrixReuseError<P>
Auto Trait Implementations
impl<P> RefUnwindSafe for MatrixReuseError<P>where
P: RefUnwindSafe,
impl<P> Send for MatrixReuseError<P>where
P: Send,
impl<P> Sync for MatrixReuseError<P>where
P: Sync,
impl<P> Unpin for MatrixReuseError<P>where
P: Unpin,
impl<P> UnwindSafe for MatrixReuseError<P>where
P: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more