[−][src]Struct canvas::CanvasReuseError
Error representation for a failed buffer reuse for a canvas.
Emitted as a result of Canvas::from_rec
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_rec
. 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 rec = Rec::<u8>::new(16); let allocation = rec.as_bytes().as_ptr(); let bad_layout = Layout::width_and_height(rec.capacity() + 1, 1).unwrap(); let error = match Canvas::from_reused_rec(rec, bad_layout) { Ok(_) => unreachable!("The layout requires one too many pixels"), Err(error) => error, }; // Get back the original buffer. let rec = error.into_rec(); assert_eq!(rec.as_bytes().as_ptr(), allocation);
Methods
impl<P: AsBytes + FromBytes> CanvasReuseError<P>
[src]
Trait Implementations
impl<P: AsBytes + FromBytes> Debug for CanvasReuseError<P>
[src]
impl<P: Eq + AsBytes + FromBytes> Eq for CanvasReuseError<P>
[src]
impl<P: PartialEq + AsBytes + FromBytes> PartialEq<CanvasReuseError<P>> for CanvasReuseError<P>
[src]
fn eq(&self, other: &CanvasReuseError<P>) -> bool
[src]
fn ne(&self, other: &CanvasReuseError<P>) -> bool
[src]
impl<P: AsBytes + FromBytes> StructuralEq for CanvasReuseError<P>
[src]
impl<P: AsBytes + FromBytes> StructuralPartialEq for CanvasReuseError<P>
[src]
Auto Trait Implementations
impl<P> RefUnwindSafe for CanvasReuseError<P> where
P: RefUnwindSafe,
P: RefUnwindSafe,
impl<P> Send for CanvasReuseError<P> where
P: Send,
P: Send,
impl<P> Sync for CanvasReuseError<P> where
P: Sync,
P: Sync,
impl<P> Unpin for CanvasReuseError<P> where
P: Unpin,
P: Unpin,
impl<P> UnwindSafe for CanvasReuseError<P> where
P: UnwindSafe,
P: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,