Struct r3_core::hunk::Hunk

source ·
pub struct Hunk<System, T: ?Sized> { /* private fields */ }
Expand description

Represents a single typed hunk in a system.

Hunks are nothing more than static variables defined in a kernel configuration. They come in handy when you are designing a component that can be instantiated by a kernel configuration and wanting each instance to have its own separate state data.

This type is implemented on top of r3::kernel::Hunk, the untyped hunk type.

Implementations

Construct a HunkDefiner to define a hunk in a configuration function.

Reinterpret the hunk as another type.

Safety
  • Similarly to core::mem::transmute, this is incredibly unsafe.
  • The byte offset must be valid for the destination type.

Calculate the offset from the hunk.

Safety
  • The resulting hunk may point to memory that the caller is not supposed to access.

Get the untyped hunk.

Get a raw pointer to the hunk’s contents.

Get a raw pointer to the raw bytes of the hunk.

Get a reference to the hunk’s contents.

Get a reference to the raw bytes of the hunk.

Safety

The result might include uninitialized bytes and/or interior mutability, so it might be unsafe to access.

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
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
The default value.

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 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.