pub struct FakeHostProbe { /* private fields */ }Expand description
A host probe that returns pre-configured host information.
This is useful for testing code that depends on HostProbe without
actually querying system information.
§Thread Safety
All configuration methods are &self (not &mut self), making it safe
to share a single instance across multiple threads in tests.
§Example
use perfgate_fake::FakeHostProbe;
use perfgate_adapters::{HostProbe, HostProbeOptions};
use perfgate_types::HostInfo;
let probe = FakeHostProbe::new()
.with_os("linux")
.with_arch("x86_64")
.with_cpu_count(8)
.with_memory_bytes(16 * 1024 * 1024 * 1024);
let options = HostProbeOptions { include_hostname_hash: false };
let info = probe.probe(&options);
assert_eq!(info.os, "linux");
assert_eq!(info.arch, "x86_64");
assert_eq!(info.cpu_count, Some(8));Implementations§
Source§impl FakeHostProbe
impl FakeHostProbe
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new FakeHostProbe with default values.
Defaults:
os: “unknown”arch: “unknown”cpu_count:Nonememory_bytes:Nonehostname_hash:None(always, unless explicitly set)
Sourcepub fn platform(os: &str, arch: &str, cpu_count: u32, memory_bytes: u64) -> Self
pub fn platform(os: &str, arch: &str, cpu_count: u32, memory_bytes: u64) -> Self
Create a FakeHostProbe that mimics a specific platform.
§Example
use perfgate_fake::FakeHostProbe;
// Create a probe that looks like a Linux system
let probe = FakeHostProbe::platform("linux", "x86_64", 8, 16 * 1024 * 1024 * 1024);Sourcepub fn with_cpu_count(self, count: u32) -> Self
pub fn with_cpu_count(self, count: u32) -> Self
Set the CPU count.
Sourcepub fn with_memory_bytes(self, bytes: u64) -> Self
pub fn with_memory_bytes(self, bytes: u64) -> Self
Set the memory in bytes.
Sourcepub fn with_hostname_hash(self, hash: &str) -> Self
pub fn with_hostname_hash(self, hash: &str) -> Self
Set the hostname hash directly.
Note: This overrides the include_hostname_hash option behavior.
If set, this value is always returned.
Sourcepub fn without_cpu_count(self) -> Self
pub fn without_cpu_count(self) -> Self
Set CPU count to None.
Sourcepub fn without_memory(self) -> Self
pub fn without_memory(self) -> Self
Set memory to None.
Trait Implementations§
Source§impl Clone for FakeHostProbe
impl Clone for FakeHostProbe
Source§fn clone(&self) -> FakeHostProbe
fn clone(&self) -> FakeHostProbe
Returns a duplicate 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 moreSource§impl Debug for FakeHostProbe
impl Debug for FakeHostProbe
Source§impl Default for FakeHostProbe
impl Default for FakeHostProbe
Source§impl HostProbe for FakeHostProbe
impl HostProbe for FakeHostProbe
fn probe(&self, options: &HostProbeOptions) -> HostInfo
Auto Trait Implementations§
impl Freeze for FakeHostProbe
impl RefUnwindSafe for FakeHostProbe
impl Send for FakeHostProbe
impl Sync for FakeHostProbe
impl Unpin for FakeHostProbe
impl UnsafeUnpin for FakeHostProbe
impl UnwindSafe for FakeHostProbe
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: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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