Struct Unique
pub struct Unique<T>where
T: UniqueType,{ /* private fields */ }Expand description
Makes sure the inner value is unique and can be safely shared across threads.
No other part of the engine will have access to the inner value and only Send + Sync or other Unique<T> values can be passed to
functions on T. Unique also blocks access to Gd::clone or to their InstanceId.
Unique supports these generally not thread safe types:
Implementations§
§impl<K, V> Unique<Dictionary<K, V>>
impl<K, V> Unique<Dictionary<K, V>>
pub fn new() -> Unique<Dictionary<K, V>>
§impl<T> Unique<Gd<T>>
impl<T> Unique<Gd<T>>
pub fn try_from_ref_counted(value: Gd<T>) -> Option<Unique<Gd<T>>>where
T: GodotClass<Declarer = DeclEngine, Memory = MemRefCounted> + Inherits<RefCounted> + Inherits<Object>,
pub fn try_from_ref_counted(value: Gd<T>) -> Option<Unique<Gd<T>>>where
T: GodotClass<Declarer = DeclEngine, Memory = MemRefCounted> + Inherits<RefCounted> + Inherits<Object>,
Attempts to verify that the provided ref-counted object is in fact unique.
This might fail if the object is referenced by anything else or any of its internal references are shared with other objects. Specific reasons for this conversion to fail:
- Reference counter is > 1.
- Reference count of any property value is > 1.
- Any property value directly inherits from Object (manually managed).
- Any property value is of type Dictionary or any of the Array types.
- Any property is a custom callable.
- Any property fails these checks recursively.
Since all checks are applied recursively to all objects which are referenced by the given value this conversion can potentially be quite expensive.
§impl<T> Unique<Gd<T>>where
T: GodotClass<Declarer = DeclEngine>,
impl<T> Unique<Gd<T>>where
T: GodotClass<Declarer = DeclEngine>,
§impl<T> Unique<Gd<T>>where
T: GodotClass<Declarer = DeclUser>,
impl<T> Unique<Gd<T>>where
T: GodotClass<Declarer = DeclUser>,
§impl<K, V> Unique<Dictionary<K, V>>
impl<K, V> Unique<Dictionary<K, V>>
pub fn apply<F>(&mut self, f: F)where
F: FnOnce(&mut Dictionary<K, V>),
Trait Implementations§
§impl<T> ThreadSafeArgContext for Unique<T>where
T: UniqueType,
impl<T> ThreadSafeArgContext for Unique<T>where
T: UniqueType,
§fn guarantee_thread_safe()
fn guarantee_thread_safe()
Panics if the value is being used in a non thread-safe context.
impl<T> AsArg<Gd<T>> for Unique<Gd<T>>where
T: GodotClass,
impl<T> AsArg<Option<Gd<T>>> for Unique<Gd<T>>where
T: GodotClass,
impl<T> Send for Unique<T>where
T: UniqueType,
impl<T> Sync for Unique<T>where
T: UniqueType,
Auto Trait Implementations§
impl<T> Freeze for Unique<T>where
T: Freeze,
impl<T> RefUnwindSafe for Unique<T>where
T: RefUnwindSafe,
impl<T> Unpin for Unique<T>where
T: Unpin,
impl<T> UnsafeUnpin for Unique<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Unique<T>where
T: UnwindSafe,
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