Struct kernel::sync::Ref

source · []
pub struct Ref<T: ?Sized> { /* private fields */ }
Expand description

A reference-counted pointer to an instance of T.

The reference count is incremented when new instances of Ref are created, and decremented when they are dropped. When the count reaches zero, the underlying T is also dropped.

Invariants

The reference count on an instance of Ref is always non-zero. The object pointed to by Ref is always pinned.

Implementations

Constructs a new reference counted instance of T.

Deconstructs a Ref object into a usize.

It can be reconstructed once via Ref::from_usize.

Borrows a Ref instance previously deconstructed via Ref::into_usize.

Safety

encoded must have been returned by a previous call to Ref::into_usize. Additionally, Ref::from_usize can only be called after all instances of RefBorrow have been dropped.

Recreates a Ref instance previously deconstructed via Ref::into_usize.

Safety

encoded must have been returned by a previous call to Ref::into_usize. Additionally, it can only be called once for each previous call to Ref::into_usize.

Determines if two reference-counted pointers point to the same underlying instance of T.

Deconstructs a Ref object into a raw pointer.

It can be reconstructed once via Ref::from_raw.

Recreates a Ref instance previously deconstructed via Ref::into_raw.

This code relies on the repr(C) layout of structs as described in https://doc.rust-lang.org/reference/type-layout.html#reprc-structs.

Safety

ptr must have been returned by a previous call to Ref::into_raw. Additionally, it can only be called once for each previous call to Ref::into_raw.

Returns a RefBorrow from the given Ref.

This is useful when the argument of a function call is a RefBorrow (e.g., in a method receiver), but we have a Ref instead. Getting a RefBorrow is free when optimised.

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

The resulting type after dereferencing.

Dereferences the value.

Cleans resources up when the device is removed. Read more

Executes the destructor for this type. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

The type of the entries in the list.

Returns the links to be used when linking an entry within a list.

Specifies which wrapper (e.g., Box and Arc) wraps the list entries.

Type of values borrowed between calls to PointerWrapper::into_pointer and PointerWrapper::from_pointer. Read more

Returns the raw pointer.

Returns a borrowed value. Read more

Returns the instance back from the raw pointer. Read more

Returns a mutably borrowed value. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Converts the wrapped object into a pointer that represents it.

Converts the object back from the pointer representation. Read more

Returns a reference to the wrapped object.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

This documentation is an old archive. Please see https://rust.docs.kernel.org instead.