Skip to main content

FakeHostProbe

Struct FakeHostProbe 

Source
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

Source

pub fn new() -> Self

Create a new FakeHostProbe with default values.

Defaults:

  • os: “unknown”
  • arch: “unknown”
  • cpu_count: None
  • memory_bytes: None
  • hostname_hash: None (always, unless explicitly set)
Source

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);
Source

pub fn with_os(self, os: &str) -> Self

Set the OS string.

Source

pub fn with_arch(self, arch: &str) -> Self

Set the architecture string.

Source

pub fn with_cpu_count(self, count: u32) -> Self

Set the CPU count.

Source

pub fn with_memory_bytes(self, bytes: u64) -> Self

Set the memory in bytes.

Source

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.

Source

pub fn without_cpu_count(self) -> Self

Set CPU count to None.

Source

pub fn without_memory(self) -> Self

Set memory to None.

Trait Implementations§

Source§

impl Clone for FakeHostProbe

Source§

fn clone(&self) -> FakeHostProbe

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FakeHostProbe

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for FakeHostProbe

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl HostProbe for FakeHostProbe

Source§

fn probe(&self, options: &HostProbeOptions) -> HostInfo

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> IntoEither for T

Source§

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 more
Source§

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
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.