pub struct Teardown<Cx: ?Sized> { /* private fields */ }Expand description
Releases a set of resources in reverse registration order — the inverse of how they were built, which is the only order that is safe when later resources borrow earlier ones.
One failure does not abandon the rest: every resource is released, and the first error is returned afterwards. A half-torn-down GPU is worse than a reported error.
Implementations§
Source§impl<Cx: ?Sized> Teardown<Cx>
impl<Cx: ?Sized> Teardown<Cx>
pub fn new() -> Self
Sourcepub fn push(&mut self, resource: Box<dyn ModelResource<Cx>>)
pub fn push(&mut self, resource: Box<dyn ModelResource<Cx>>)
Register a resource. Registration order is construction order.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn release_all(&mut self, cx: &Cx) -> Result<()>
pub fn release_all(&mut self, cx: &Cx) -> Result<()>
Release everything, newest first. Returns the first failure, after having attempted them all.
Trait Implementations§
Auto Trait Implementations§
impl<Cx> Freeze for Teardown<Cx>where
Cx: ?Sized,
impl<Cx> !RefUnwindSafe for Teardown<Cx>
impl<Cx> Send for Teardown<Cx>where
Cx: ?Sized,
impl<Cx> Sync for Teardown<Cx>where
Cx: ?Sized,
impl<Cx> Unpin for Teardown<Cx>where
Cx: ?Sized,
impl<Cx> !UnwindSafe for Teardown<Cx>
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