Struct r3::hunk::Hunk

source ·
pub struct Hunk<System, T>where
    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, T> Hunk<System, T>where System: KernelBase + KernelStatic<System>, T: ?Sized,

source

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

Available on crate feature sync only.

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

source§

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

source

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

Available on crate feature sync only.

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) -> Hunk<System, T>

Available on crate feature sync only.

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, T> Hunk<System, T>where System: KernelBase + KernelStatic<System>, T: ?Sized,

source

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

Available on crate feature sync only.

Get the untyped hunk.

source

pub fn as_ptr(this: Hunk<System, T>) -> *const T

Available on crate feature sync only.

Get a raw pointer to the hunk’s contents.

source

pub fn as_bytes_ptr(this: Hunk<System, T>) -> *const [u8]

Available on crate feature sync only.

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

source

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

Available on crate feature sync only.

Get a reference to the hunk’s contents.

source

pub unsafe fn as_bytes(this: Hunk<System, T>) -> &'static [u8]

Available on crate feature sync only.

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, T> AsRef<T> for Hunk<System, T>where System: KernelBase + KernelStatic<System>, T: ?Sized,

source§

fn as_ref(&self) -> &T

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

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

source§

fn clone(&self) -> Hunk<System, T>

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

source§

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

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

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

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &<Hunk<System, T> as Deref>::Target

Dereferences the value.
source§

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

source§

const INIT: Hunk<System, [T]> = Self{ offset: slice_from_raw_parts_mut(core::ptr::null_mut(), 0), _phantom: PhantomData,}

The default value.
source§

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

source§

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

source§

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

source§

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

source§

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

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.