pub struct MemorySize(pub u64);Expand description
The size of an object in memory, in bytes.
The helper methods on this type use powers of 2 for conversions between units, consistent with the standards for memory reporting.
While it would technically be more correct to use e.g. “kibibytes” instead of “kilobytes”, “mebibytes” instead of “megabytes”, etc., the more common terms are used here for familiarity and discoverability.
Tuple Fields§
§0: u64Implementations§
Source§impl MemorySize
impl MemorySize
Sourcepub fn new(bytes: usize) -> MemorySize
pub fn new(bytes: usize) -> MemorySize
Creates a new MemorySize from the given number of bytes.
This method is provided for convenience,
as many other APIs in Rust use usize for sizes and counts.
To initialize this type with a u64, just call MemorySize(bytes) directly.
Sourcepub fn as_bytes(&self) -> usize
pub fn as_bytes(&self) -> usize
Returns the size in bytes, as a usize.
This method is provided for convenience,
as many other APIs in Rust use usize for sizes and counts.
To access the value as a u64, just use the .0 field directly.
1 byte = 8 bits.
Sourcepub fn as_kilobytes(&self) -> f64
pub fn as_kilobytes(&self) -> f64
Returns the size in kilobytes.
1 kilobyte = 1024 bytes.
Sourcepub fn as_megabytes(&self) -> f64
pub fn as_megabytes(&self) -> f64
Returns the size in megabytes.
1 megabyte = 1024 kilobytes.
Sourcepub fn as_gigabytes(&self) -> f64
pub fn as_gigabytes(&self) -> f64
Returns the size in gigabytes.
1 gigabyte = 1024 megabytes.
Sourcepub fn as_terabytes(&self) -> f64
pub fn as_terabytes(&self) -> f64
Returns the size in terabytes.
1 terabyte = 1024 gigabytes.
Sourcepub fn appropriate_unit(&self) -> MemoryUnit
pub fn appropriate_unit(&self) -> MemoryUnit
Determine the appropriate unit for displaying the memory size.
Units are chosen such that the value is at least 1 in that unit.
This is used for formatting the memory size in a human-readable way,
such as in the Display implementation for this type.
Trait Implementations§
Source§impl Clone for MemorySize
impl Clone for MemorySize
Source§fn clone(&self) -> MemorySize
fn clone(&self) -> MemorySize
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for MemorySize
Source§impl Debug for MemorySize
impl Debug for MemorySize
Source§impl Display for MemorySize
impl Display for MemorySize
impl Eq for MemorySize
Source§impl Ord for MemorySize
impl Ord for MemorySize
Source§fn cmp(&self, other: &MemorySize) -> Ordering
fn cmp(&self, other: &MemorySize) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for MemorySize
impl PartialEq for MemorySize
Source§impl PartialOrd for MemorySize
impl PartialOrd for MemorySize
impl StructuralPartialEq for MemorySize
Auto Trait Implementations§
impl Freeze for MemorySize
impl RefUnwindSafe for MemorySize
impl Send for MemorySize
impl Sync for MemorySize
impl Unpin for MemorySize
impl UnsafeUnpin for MemorySize
impl UnwindSafe for MemorySize
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
self.