Skip to main content

ClientHandle

Struct ClientHandle 

Source
pub struct ClientHandle { /* private fields */ }
Expand description

Handle for a single client/task instance.

The handle owns the task identity and start time, and emits partial updates using those fields as a stable base.

Implementations§

Source§

impl ClientHandle

Source

pub fn id(&self) -> TaskId

Return the internal identifier for this client/task.

Source

pub fn set_label(&self, label: impl Into<String>) -> Result<(), ReportError>

Update the display label for this client/task.

Source

pub fn set_total(&self, total: Option<u64>) -> Result<(), ReportError>

Update the total units of work for this client/task.

Use None for an indeterminate total.

Source

pub fn set_current(&self, current: u64) -> Result<(), ReportError>

Set the current completed units of work.

Examples found in repository?
examples/dummy_project/dummy_cluster.rs (line 39)
28    pub fn run(&self, steps: usize, reporter: ClientReporter) {
29        let mut handles = Vec::with_capacity(self.count);
30        for i in 0..self.count {
31            let reporter = reporter.clone();
32            let label = format!("sim-{i}");
33            handles.push(thread::spawn(move || {
34                let mut sim = DummySimulator::new();
35                let client = reporter.start(label, Some(steps as u64));
36                if let Ok(client) = client {
37                    for _ in 0..steps {
38                        sim.tick();
39                        let _ = client.set_current(sim.step as u64);
40                    }
41                    let _ = client.complete();
42                }
43                sim
44            }));
45        }
46
47        for handle in handles {
48            let _ = handle.join();
49        }
50    }
Source

pub fn complete(&self) -> Result<(), ReportError>

Mark this client/task as completed.

Examples found in repository?
examples/dummy_project/dummy_cluster.rs (line 41)
28    pub fn run(&self, steps: usize, reporter: ClientReporter) {
29        let mut handles = Vec::with_capacity(self.count);
30        for i in 0..self.count {
31            let reporter = reporter.clone();
32            let label = format!("sim-{i}");
33            handles.push(thread::spawn(move || {
34                let mut sim = DummySimulator::new();
35                let client = reporter.start(label, Some(steps as u64));
36                if let Ok(client) = client {
37                    for _ in 0..steps {
38                        sim.tick();
39                        let _ = client.set_current(sim.step as u64);
40                    }
41                    let _ = client.complete();
42                }
43                sim
44            }));
45        }
46
47        for handle in handles {
48            let _ = handle.join();
49        }
50    }
Source

pub fn fail(&self) -> Result<(), ReportError>

Mark this client/task as failed.

Source

pub fn cancel(&self) -> Result<(), ReportError>

Mark this client/task as canceled.

Trait Implementations§

Source§

impl Clone for ClientHandle

Source§

fn clone(&self) -> ClientHandle

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

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V