Struct sysinfo::MemoryRefreshKind
source · pub struct MemoryRefreshKind { /* private fields */ }
Expand description
Used to determine which memory you want to refresh specifically.
⚠️ Just like all other refresh types, ruling out a refresh doesn’t assure you that the information won’t be retrieved if the information is accessible without needing extra computation.
use sysinfo::{MemoryRefreshKind, System};
let mut system = System::new();
// We don't want to update all memories information.
system.refresh_memory_specifics(MemoryRefreshKind::new().with_ram());
println!("total RAM: {}", system.total_memory());
println!("free RAM: {}", system.free_memory());
Implementations§
source§impl MemoryRefreshKind
impl MemoryRefreshKind
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new MemoryRefreshKind
with every refresh set to false
.
use sysinfo::MemoryRefreshKind;
let r = MemoryRefreshKind::new();
assert_eq!(r.ram(), false);
assert_eq!(r.swap(), false);
sourcepub fn everything() -> Self
pub fn everything() -> Self
Creates a new MemoryRefreshKind
with every refresh set to true
.
use sysinfo::MemoryRefreshKind;
let r = MemoryRefreshKind::everything();
assert_eq!(r.ram(), true);
assert_eq!(r.swap(), true);
sourcepub fn ram(&self) -> bool
pub fn ram(&self) -> bool
Returns the value of the “ram” refresh kind.
use sysinfo::MemoryRefreshKind;
let r = MemoryRefreshKind::new();
assert_eq!(r.ram(), false);
let r = r.with_ram();
assert_eq!(r.ram(), true);
let r = r.without_ram();
assert_eq!(r.ram(), false);
sourcepub fn with_ram(self) -> Self
pub fn with_ram(self) -> Self
Sets the value of the “ram” refresh kind to true
.
use sysinfo::MemoryRefreshKind;
let r = MemoryRefreshKind::new();
assert_eq!(r.ram(), false);
let r = r.with_ram();
assert_eq!(r.ram(), true);
sourcepub fn without_ram(self) -> Self
pub fn without_ram(self) -> Self
Sets the value of the “ram” refresh kind to false
.
use sysinfo::MemoryRefreshKind;
let r = MemoryRefreshKind::everything();
assert_eq!(r.ram(), true);
let r = r.without_ram();
assert_eq!(r.ram(), false);
sourcepub fn swap(&self) -> bool
pub fn swap(&self) -> bool
Returns the value of the “swap” refresh kind.
use sysinfo::MemoryRefreshKind;
let r = MemoryRefreshKind::new();
assert_eq!(r.swap(), false);
let r = r.with_swap();
assert_eq!(r.swap(), true);
let r = r.without_swap();
assert_eq!(r.swap(), false);
sourcepub fn with_swap(self) -> Self
pub fn with_swap(self) -> Self
Sets the value of the “swap” refresh kind to true
.
use sysinfo::MemoryRefreshKind;
let r = MemoryRefreshKind::new();
assert_eq!(r.swap(), false);
let r = r.with_swap();
assert_eq!(r.swap(), true);
sourcepub fn without_swap(self) -> Self
pub fn without_swap(self) -> Self
Sets the value of the “swap” refresh kind to false
.
use sysinfo::MemoryRefreshKind;
let r = MemoryRefreshKind::everything();
assert_eq!(r.swap(), true);
let r = r.without_swap();
assert_eq!(r.swap(), false);
Trait Implementations§
source§impl Clone for MemoryRefreshKind
impl Clone for MemoryRefreshKind
source§fn clone(&self) -> MemoryRefreshKind
fn clone(&self) -> MemoryRefreshKind
Returns a copy of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for MemoryRefreshKind
impl Debug for MemoryRefreshKind
source§impl Default for MemoryRefreshKind
impl Default for MemoryRefreshKind
source§fn default() -> MemoryRefreshKind
fn default() -> MemoryRefreshKind
Returns the “default value” for a type. Read more
source§impl PartialEq for MemoryRefreshKind
impl PartialEq for MemoryRefreshKind
impl Copy for MemoryRefreshKind
impl Eq for MemoryRefreshKind
impl StructuralPartialEq for MemoryRefreshKind
Auto Trait Implementations§
impl Freeze for MemoryRefreshKind
impl RefUnwindSafe for MemoryRefreshKind
impl Send for MemoryRefreshKind
impl Sync for MemoryRefreshKind
impl Unpin for MemoryRefreshKind
impl UnwindSafe for MemoryRefreshKind
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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
)§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more