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)
pub fn apply<F>(&mut self, f: F)
Apply modifications to unique instance of the inner type.
All captured outer variables must be thread-safe.
§impl<T> Unique<T>where
T: UniqueType,
impl<T> Unique<T>where
T: UniqueType,
Unwraps the inner value and gives up all uniqueness guarantees.