pub struct ManagedClient;Expand description
Entry point for constructing a unified Tokio managed task.
§Example
Construct the task and its separate control handle, subscribe before starting the task, then run it under the caller’s Tokio runtime. A reachable server is required at runtime, so this example only type-checks.
use irtt_client::{ClientConfig, ClientEvent};
use irtt_client::managed::{
ManagedClient, ManagedClientConfig, ManagedEvent, ManagedTargetConfig,
};
let config = ManagedClientConfig {
client: ClientConfig {
request: irtt_client::SessionRequest {
duration: Some(std::time::Duration::from_secs(10)),
..irtt_client::SessionRequest::default()
},
..ClientConfig::default()
},
..ManagedClientConfig::default()
};
let targets = vec![ManagedTargetConfig::new("edge", "127.0.0.1:2112")];
let (task, handle) = ManagedClient::task(config, targets)?;
let mut events = handle.subscribe()?;
let driver = tokio::spawn(task);
while let Ok(event) = events.recv().await {
if let ManagedEvent::Client { event: ClientEvent::EchoReply { .. }, .. } = event {
println!("received a probe reply");
}
}
let outcome = driver.await?;
println!("run ended: {:?}", outcome.end_reason);Implementations§
Source§impl ManagedClient
impl ManagedClient
Sourcepub fn task(
config: ManagedClientConfig,
targets: Vec<ManagedTargetConfig>,
) -> Result<(ManagedClientTask, ManagedClientHandle), ManagedConfigError>
pub fn task( config: ManagedClientConfig, targets: Vec<ManagedTargetConfig>, ) -> Result<(ManagedClientTask, ManagedClientHandle), ManagedConfigError>
Validate configuration and construct a runtime-independent task/handle pair.
Trait Implementations§
Source§impl Debug for ManagedClient
impl Debug for ManagedClient
Auto Trait Implementations§
impl Freeze for ManagedClient
impl RefUnwindSafe for ManagedClient
impl Send for ManagedClient
impl Sync for ManagedClient
impl Unpin for ManagedClient
impl UnsafeUnpin for ManagedClient
impl UnwindSafe for ManagedClient
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