Skip to main content

MemoryScopes

Struct MemoryScopes 

Source
#[non_exhaustive]
pub struct MemoryScopes { pub tag: fn(u8, &'static str) -> u16, pub enter: fn(u16) -> u16, pub leave: fn(u16), }
Expand description

How a backend lets the engine tag what it allocates (ADR-0046 §6): three plain functions over its heap counter’s tags (shuyi_platform::Platform::memory_scopes), so neither this crate nor the platform depends on the counter. Build it with MemoryScopes::new (ADR-0039).

With scopes in its context (Ctx::set_memory_scopes), the game’s frame enters update and draw, each Ctx::span its own name, and the platform’s App its own phases. Entering a tag changes nothing a game reads.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§tag: fn(u8, &'static str) -> u16

The tag of a name of a class (TagClass as a number), the same each time it is asked for.

§enter: fn(u16) -> u16

Makes a tag the current one, and gives back the one before.

§leave: fn(u16)

Puts back the tag enter gave.

Implementations§

Source§

impl MemoryScopes

Source

pub const fn new( tag: fn(u8, &'static str) -> u16, enter: fn(u16) -> u16, leave: fn(u16), ) -> Self

Scopes that find a tag with tag, and enter and leave it.

Source

pub fn enter(&self, class: TagClass, name: &'static str) -> u16

Enters the tag of class’s name, and gives back the tag before, for leave.

Source

pub fn leave(&self, before: u16)

Puts back before, the tag enter gave.

Trait Implementations§

Source§

impl Clone for MemoryScopes

Source§

fn clone(&self) -> MemoryScopes

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for MemoryScopes

Source§

impl Debug for MemoryScopes

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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.