primitives/prelude/traits/disposable.rs
1/// The Disposable should be implemented by objects that require
2/// specialised garbage collection or memory deallocation.
3///
4/// Once an object is disposed it should be automatically removed from parent heirachies.
5///
6pub trait Disposable {
7 /// Returns true if the object has been disposed (or is being disposed).
8 fn is_disposed(&self) -> bool;
9
10 /// Disposes this object by deallocating all used resources and breaking all
11 /// (non-weak) references to other objects. This method must be the final
12 /// call in the object's life cycle. No methods except this method should be
13 /// called on the object and no properties of the object should be read or
14 /// written after a call to this object; otherwise the behaviour is
15 /// unreliable. The object may call the method on itself, directly or
16 /// indirectly.
17 fn dispose(&self);
18}