Struct bones_lib::ecs::prelude::CurrentSystemStage
pub struct CurrentSystemStage(pub Ulid);
Expand description
Resource that is automatically added to the world while a system stage is being run that specifies the unique ID of the stage that being run.
If the stage is Ulid(0)
, the default ID, then that means the startup stage is being run.
Tuple Fields§
§0: Ulid
Methods from Deref<Target = Ulid>§
pub fn datetime(&self) -> SystemTime
pub fn datetime(&self) -> SystemTime
Gets the datetime of when this Ulid was created accurate to 1ms
§Example
use std::time::{SystemTime, Duration};
use ulid::Ulid;
let dt = SystemTime::now();
let ulid = Ulid::from_datetime(dt);
assert!(
dt + Duration::from_millis(1) >= ulid.datetime()
&& dt - Duration::from_millis(1) <= ulid.datetime()
);
pub const TIME_BITS: u8 = 48u8
pub const RAND_BITS: u8 = 80u8
pub fn timestamp_ms(&self) -> u64
pub fn timestamp_ms(&self) -> u64
Gets the timestamp section of this ulid
§Example
use std::time::{SystemTime, Duration};
use ulid::Ulid;
let dt = SystemTime::now();
let ulid = Ulid::from_datetime(dt);
assert_eq!(u128::from(ulid.timestamp_ms()), dt.duration_since(SystemTime::UNIX_EPOCH).unwrap_or(Duration::ZERO).as_millis());
pub fn random(&self) -> u128
pub fn random(&self) -> u128
Gets the random section of this ulid
§Example
use ulid::Ulid;
let text = "01D39ZY06FGSCTVN4T2V9PKHFZ";
let ulid = Ulid::from_string(text).unwrap();
let ulid_next = ulid.increment().unwrap();
assert_eq!(ulid.random() + 1, ulid_next.random());
pub fn to_str<'buf>(
&self,
buf: &'buf mut [u8],
) -> Result<&'buf mut str, EncodeError>
👎Deprecated since 1.2.0: Use the infallible array_to_str
instead.
pub fn to_str<'buf>( &self, buf: &'buf mut [u8], ) -> Result<&'buf mut str, EncodeError>
array_to_str
instead.Creates a Crockford Base32 encoded string that represents this Ulid
§Example
use ulid::Ulid;
let text = "01D39ZY06FGSCTVN4T2V9PKHFZ";
let ulid = Ulid::from_string(text).unwrap();
let mut buf = [0; ulid::ULID_LEN];
let new_text = ulid.to_str(&mut buf).unwrap();
assert_eq!(new_text, text);
pub fn array_to_str<'buf>(&self, buf: &'buf mut [u8; 26]) -> &'buf mut str
pub fn array_to_str<'buf>(&self, buf: &'buf mut [u8; 26]) -> &'buf mut str
Creates a Crockford Base32 encoded string that represents this Ulid
§Example
use ulid::Ulid;
let text = "01D39ZY06FGSCTVN4T2V9PKHFZ";
let ulid = Ulid::from_string(text).unwrap();
let mut buf = [0; ulid::ULID_LEN];
let new_text = ulid.array_to_str(&mut buf);
assert_eq!(new_text, text);
pub fn to_string(&self) -> String
pub fn to_string(&self) -> String
Creates a Crockford Base32 encoded string that represents this Ulid
§Example
use ulid::Ulid;
let text = "01D39ZY06FGSCTVN4T2V9PKHFZ";
let ulid = Ulid::from_string(text).unwrap();
assert_eq!(&ulid.to_string(), text);
pub fn is_nil(&self) -> bool
pub fn is_nil(&self) -> bool
Test if the Ulid is nil
§Example
use ulid::Ulid;
let ulid = Ulid::new();
assert!(!ulid.is_nil());
let nil = Ulid::nil();
assert!(nil.is_nil());
Trait Implementations§
§impl Clone for CurrentSystemStage
impl Clone for CurrentSystemStage
§fn clone(&self) -> CurrentSystemStage
fn clone(&self) -> CurrentSystemStage
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl Default for CurrentSystemStage
impl Default for CurrentSystemStage
§fn default() -> CurrentSystemStage
fn default() -> CurrentSystemStage
Returns the “default value” for a type. Read more
§impl Deref for CurrentSystemStage
impl Deref for CurrentSystemStage
§impl DerefMut for CurrentSystemStage
impl DerefMut for CurrentSystemStage
§fn deref_mut(&mut self) -> &mut <CurrentSystemStage as Deref>::Target
fn deref_mut(&mut self) -> &mut <CurrentSystemStage as Deref>::Target
Mutably dereferences the value.
§impl HasSchema for CurrentSystemStage
impl HasSchema for CurrentSystemStage
§fn register_schema()
fn register_schema()
Register this schema with the global schema registry. Read more
§fn cast<T>(this: &Self) -> &Twhere
T: HasSchema,
fn cast<T>(this: &Self) -> &Twhere
T: HasSchema,
Cast a reference of this type to a reference of another type with the same memory layout. Read more
§fn try_cast<T>(this: &Self) -> Result<&T, SchemaMismatchError>where
T: HasSchema,
fn try_cast<T>(this: &Self) -> Result<&T, SchemaMismatchError>where
T: HasSchema,
Cast a reference of this type to a reference of another type with the same memory layout. Read more
§fn cast_mut<T>(this: &mut Self) -> &mut Twhere
T: HasSchema,
fn cast_mut<T>(this: &mut Self) -> &mut Twhere
T: HasSchema,
Cast a mutable reference of this type to a reference of another type with the same memory
layout. Read more
§fn try_cast_mut<T>(this: &mut Self) -> Result<&mut T, SchemaMismatchError>where
T: HasSchema,
fn try_cast_mut<T>(this: &mut Self) -> Result<&mut T, SchemaMismatchError>where
T: HasSchema,
Cast a mutable reference of this type to a reference of another type with the same memory
layout. Read more
§fn as_schema_ref(&self) -> SchemaRef<'_>where
Self: Sized,
fn as_schema_ref(&self) -> SchemaRef<'_>where
Self: Sized,
Converts a reference of
T
to a SchemaRef
§fn as_schema_mut(&mut self) -> SchemaRefMut<'_>where
Self: Sized,
fn as_schema_mut(&mut self) -> SchemaRefMut<'_>where
Self: Sized,
Converts a reference of
T
to a SchemaRefMut
impl Copy for CurrentSystemStage
Auto Trait Implementations§
impl Freeze for CurrentSystemStage
impl RefUnwindSafe for CurrentSystemStage
impl Send for CurrentSystemStage
impl Sync for CurrentSystemStage
impl Unpin for CurrentSystemStage
impl UnwindSafe for CurrentSystemStage
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &World) -> T
fn from_world(_world: &World) -> T
Creates
Self
using data from the given World
.