Trait archery::shared_pointer::kind::SharedPointerKind
source · pub unsafe trait SharedPointerKind: Sized + Debug {
// Required methods
fn new<T>(v: T) -> Self;
fn from_box<T>(v: Box<T>) -> Self;
unsafe fn as_ptr<T>(&self) -> *const T;
unsafe fn deref<T>(&self) -> &T;
unsafe fn try_unwrap<T>(self) -> Result<T, Self>;
unsafe fn get_mut<T>(&mut self) -> Option<&mut T>;
unsafe fn make_mut<T: Clone>(&mut self) -> &mut T;
unsafe fn strong_count<T>(&self) -> usize;
unsafe fn clone<T>(&self) -> Self;
unsafe fn drop<T>(&mut self);
}
Expand description
Trait for type constructors of reference-counting pointers.
§Safety
T
may be !
Unpin
, and SharedPointer
may be held in a pinned
form (Pin
<SharedPointer<T, Self>>
).
As such, the implementation of this trait must uphold the pinning invariants
for T
while it’s held in Self
. Specifically, this necessitates the
following:
-
&mut T
is only exposed through the trait methods returning&mut T
. -
The implementor must not move out the contained
T
unless the semantics of trait methods demands that. -
Self::drop
dropsT
in place.
Required Methods§
fn new<T>(v: T) -> Self
fn from_box<T>(v: Box<T>) -> Self
unsafe fn as_ptr<T>(&self) -> *const T
unsafe fn deref<T>(&self) -> &T
unsafe fn try_unwrap<T>(self) -> Result<T, Self>
unsafe fn get_mut<T>(&mut self) -> Option<&mut T>
unsafe fn make_mut<T: Clone>(&mut self) -> &mut T
unsafe fn strong_count<T>(&self) -> usize
unsafe fn clone<T>(&self) -> Self
unsafe fn drop<T>(&mut self)
Object Safety§
This trait is not object safe.