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§

source§

impl<System: KernelBase + KernelStatic, T: ?Sized> Hunk<System, T>

source

pub const fn define() -> HunkDefiner<System, T, DefaultInitTag>

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

source§

impl<System, T: ?Sized> Hunk<System, T>

source

pub const unsafe fn transmute<U>(self) -> Hunk<System, U>

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

pub const unsafe fn wrapping_offset(self, count: isize) -> Selfwhere T: Sized,

Calculate the offset from the hunk.

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

impl<System: KernelBase + KernelStatic, T: ?Sized> Hunk<System, T>

source

pub fn untyped_hunk(this: Self) -> Hunk<System>

Get the untyped hunk.

source

pub fn as_ptr(this: Self) -> *const T

Get a raw pointer to the hunk’s contents.

source

pub fn as_bytes_ptr(this: Self) -> *const [u8]

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

source

pub fn as_ref<'a>(this: Self) -> &'a Twhere T: 'a,

Get a reference to the hunk’s contents.

source

pub unsafe fn as_bytes(this: Self) -> &'static [u8]

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§

source§

impl<System: KernelBase + KernelStatic, T: ?Sized> AsRef<T> for Hunk<System, T>

source§

fn as_ref(&self) -> &T

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

impl<System, T: ?Sized> Clone for Hunk<System, T>

source§

fn clone(&self) -> Self

Returns a copy 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<System: KernelBase + KernelStatic, T: Debug + ?Sized> Debug for Hunk<System, T>

source§

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

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

impl<System: KernelBase + KernelStatic, T: ?Sized> Deref for Hunk<System, T>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<System: KernelBase + KernelStatic, T> Init for Hunk<System, [T]>

source§

const INIT: Self = _

The default value.
source§

impl<System: KernelBase + KernelStatic, T: ?Sized> CloneStableDeref for Hunk<System, T>

source§

impl<System, T: ?Sized> Copy for Hunk<System, T>

source§

impl<System, T: ?Sized + Send> Send for Hunk<System, T>

source§

impl<System: KernelBase + KernelStatic, T: ?Sized> StableDeref for Hunk<System, T>

source§

impl<System, T: ?Sized + Sync> Sync for Hunk<System, T>

Auto Trait Implementations§

§

impl<System, T: ?Sized> RefUnwindSafe for Hunk<System, T>where System: RefUnwindSafe, T: RefUnwindSafe,

§

impl<System, T: ?Sized> Unpin for Hunk<System, T>where System: Unpin,

§

impl<System, T: ?Sized> UnwindSafe for Hunk<System, T>where System: UnwindSafe, T: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.