Skip to main content

RcWeak

Struct RcWeak 

Source
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§

Source§

impl<T> RcWeak<T>

Source

pub fn new() -> Self

Source§

impl<T: ?Sized> RcWeak<T>

Source

pub fn upgrade(&self) -> Option<Rc<T>>

Source

pub fn strong_count(&self) -> usize

Source

pub fn weak_count(&self) -> usize

Source

pub fn ptr_eq(&self, other: &Self) -> bool

Source

pub fn update(&self, weak: Weak<T>)

Source

pub fn from_std(weak: Weak<T>) -> Self

Trait Implementations§

Source§

impl<T: ?Sized> Clone for RcWeak<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: ?Sized> Debug for RcWeak<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for RcWeak<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: ForyDefault> ForyDefault for RcWeak<T>

Source§

fn fory_default() -> Self

Creates a default value for this type. Read more
Source§

impl<T: ?Sized> From<&Rc<T>> for RcWeak<T>

Source§

fn from(rc: &Rc<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: ?Sized> PartialEq for RcWeak<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Serializer + ForyDefault + 'static> Serializer for RcWeak<T>

Source§

fn fory_is_shared_ref() -> bool

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>

Entry point for serialization. Read more
Source§

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>

[USER IMPLEMENTATION REQUIRED] Serialize the type’s data to the buffer. Read more
Source§

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>

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>

Deserialize with pre-read type information. Read more
Source§

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>

Read and validate type metadata from the buffer. Read more
Source§

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>

Get the registered type ID from the type resolver. Read more
Source§

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>

[USER IMPLEMENTATION REQUIRED] Get the runtime type ID for this instance. Read more
Source§

fn fory_static_type_id() -> TypeId

Get the static Fory type ID for this type. Read more
Source§

fn as_any(&self) -> &dyn Any

[USER IMPLEMENTATION REQUIRED] Downcast to &dyn Any for dynamic type checking. Read more
Source§

fn fory_is_option() -> bool
where Self: Sized,

Check if this type is Option<T>. Read more
Source§

fn fory_is_none(&self) -> bool

Check if this instance represents a None value. Read more
Source§

fn fory_is_polymorphic() -> bool
where Self: Sized,

Check if this type supports polymorphic serialization. Read more
Source§

fn fory_is_wrapper_type() -> bool
where Self: Sized,

Source§

fn fory_concrete_type_id(&self) -> TypeId

Get Rust’s std::any::TypeId for this instance. Read more
Source§

impl<T: ?Sized> Eq for RcWeak<T>

Source§

impl<T: ?Sized> Send for RcWeak<T>
where Weak<T>: Send,

Source§

impl<T: ?Sized> Sync for RcWeak<T>
where Weak<T>: Sync,

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.