pub struct RcWeak<T: ?Sized> { /* private fields */ }Expand description
A serializable wrapper around std::rc::Weak<T>.
RcWeak<T> is designed for use in graph-like structures where nodes may need to hold
non-owning references to other nodes (e.g., parent pointers), and you still want them
to round-trip through serialization while preserving reference identity.
Unlike a raw Weak<T>, cloning RcWeak keeps all clones pointing to the same
internal UnsafeCell, so updates via deserialization callbacks affect all copies.
§Example
See module-level docs for a complete graph example.
§Null handling
If the target Rc<T> has been dropped or never assigned, upgrade() returns None
and serialization will write a RefFlag::Null instead of a reference ID.
Implementations§
Trait Implementations§
Source§impl<T: ForyDefault> ForyDefault for RcWeak<T>
impl<T: ForyDefault> ForyDefault for RcWeak<T>
Source§fn fory_default() -> Self
fn fory_default() -> Self
Creates a default value for this type. Read more
Source§impl<T: Serializer + ForyDefault + 'static> Serializer for RcWeak<T>
impl<T: Serializer + ForyDefault + 'static> Serializer for RcWeak<T>
Check if this type is a shared reference (Rc/Arc). Read more
Source§fn fory_write(
&self,
context: &mut WriteContext<'_>,
ref_mode: RefMode,
write_type_info: bool,
has_generics: bool,
) -> Result<(), Error>
fn fory_write( &self, context: &mut WriteContext<'_>, ref_mode: RefMode, write_type_info: bool, has_generics: bool, ) -> Result<(), Error>
Entry point for serialization. Read more
Source§fn fory_write_data_generic(
&self,
_: &mut WriteContext<'_>,
_: bool,
) -> Result<(), Error>
fn fory_write_data_generic( &self, _: &mut WriteContext<'_>, _: bool, ) -> Result<(), Error>
Write data with generic type parameter support. Read more
Source§fn fory_write_data(&self, _: &mut WriteContext<'_>) -> Result<(), Error>
fn fory_write_data(&self, _: &mut WriteContext<'_>) -> Result<(), Error>
[USER IMPLEMENTATION REQUIRED] Serialize the type’s data to the buffer. Read more
Source§fn fory_write_type_info(context: &mut WriteContext<'_>) -> Result<(), Error>
fn fory_write_type_info(context: &mut WriteContext<'_>) -> Result<(), Error>
Write type metadata to the buffer. Read more
Source§fn fory_read(
context: &mut ReadContext<'_>,
ref_mode: RefMode,
read_type_info: bool,
) -> Result<Self, Error>
fn fory_read( context: &mut ReadContext<'_>, ref_mode: RefMode, read_type_info: bool, ) -> Result<Self, Error>
Entry point for deserialization. Read more
Source§fn fory_read_with_type_info(
context: &mut ReadContext<'_>,
ref_mode: RefMode,
typeinfo: Rc<TypeInfo>,
) -> Result<Self, Error>
fn fory_read_with_type_info( context: &mut ReadContext<'_>, ref_mode: RefMode, typeinfo: Rc<TypeInfo>, ) -> Result<Self, Error>
Deserialize with pre-read type information. Read more
Source§fn fory_read_data(_: &mut ReadContext<'_>) -> Result<Self, Error>
fn fory_read_data(_: &mut ReadContext<'_>) -> Result<Self, Error>
[USER IMPLEMENTATION REQUIRED] Deserialize the type’s data from the buffer. Read more
Source§fn fory_read_type_info(context: &mut ReadContext<'_>) -> Result<(), Error>
fn fory_read_type_info(context: &mut ReadContext<'_>) -> Result<(), Error>
Read and validate type metadata from the buffer. Read more
Source§fn fory_reserved_space() -> usize
fn fory_reserved_space() -> usize
Hint for buffer pre-allocation size. Read more
Source§fn fory_get_type_id(type_resolver: &TypeResolver) -> Result<TypeId, Error>
fn fory_get_type_id(type_resolver: &TypeResolver) -> Result<TypeId, Error>
Get the registered type ID from the type resolver. Read more
fn fory_get_type_info( type_resolver: &TypeResolver, ) -> Result<Rc<TypeInfo>, Error>
Source§fn fory_type_id_dyn(
&self,
type_resolver: &TypeResolver,
) -> Result<TypeId, Error>
fn fory_type_id_dyn( &self, type_resolver: &TypeResolver, ) -> Result<TypeId, Error>
[USER IMPLEMENTATION REQUIRED] Get the runtime type ID for this instance. Read more
Source§fn fory_static_type_id() -> TypeId
fn fory_static_type_id() -> TypeId
Get the static Fory type ID for this type. Read more
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
[USER IMPLEMENTATION REQUIRED] Downcast to
&dyn Any for dynamic type checking. Read moreSource§fn fory_is_none(&self) -> bool
fn fory_is_none(&self) -> bool
Check if this instance represents a
None value. Read moreSource§fn fory_is_polymorphic() -> boolwhere
Self: Sized,
fn fory_is_polymorphic() -> boolwhere
Self: Sized,
Check if this type supports polymorphic serialization. Read more
fn fory_is_wrapper_type() -> boolwhere
Self: Sized,
Source§fn fory_concrete_type_id(&self) -> TypeId
fn fory_concrete_type_id(&self) -> TypeId
Get Rust’s
std::any::TypeId for this instance. Read moreimpl<T: ?Sized> Eq for RcWeak<T>
impl<T: ?Sized> Send for RcWeak<T>
impl<T: ?Sized> Sync for RcWeak<T>
Auto Trait Implementations§
impl<T> Freeze for RcWeak<T>where
T: ?Sized,
impl<T> !RefUnwindSafe for RcWeak<T>
impl<T> Unpin for RcWeak<T>where
T: ?Sized,
impl<T> !UnwindSafe for RcWeak<T>
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