Struct RawClient
pub struct RawClient {
requests: UnboundedSender<Outgoing>,
indications: WeakSender<Message>,
timeout: Duration,
}Expand description
Untyped client for one QMI service.
It sends requests from raw TLVs and returns the responses without checking
them. Use it for a service that has no marker type. A
Client adds types on top.
The client prepares requests. Its Connection sends
them and receives the responses and indications, so it must run for
requests to complete. Requests can run concurrently. Cloning the client is
cheap. Dropping every clone stops the connection.
Error::TooManyRequests only limits the requests in flight. Requests
that wait for the connection to run are queued in memory without a limit.
§Example
use std::time::Duration;
use ql_qmi::RawClient;
use ql_qmi::codec::TlvWriter;
let (client, connection) = RawClient::builder(0x401, 1).connect()?;
tokio::spawn(connection.run());
let response = client
.raw_request(0x507, TlvWriter::new())
.timeout(Duration::from_secs(5))
.await?;
println!("{response:?}");Fields§
§requests: UnboundedSender<Outgoing>§indications: WeakSender<Message>Weak, so that subscribers see the channel close once the connection stops.
timeout: DurationImplementations§
§impl RawClient
impl RawClient
pub const fn builder(service: u32, version: u8) -> RawClientBuilder
pub const fn builder(service: u32, version: u8) -> RawClientBuilder
Returns a builder for a client of a QMI service.
version is the IDL major version of the service.
pub(super) const fn new( requests: UnboundedSender<Outgoing>, indications: WeakSender<Message>, timeout: Duration, ) -> Self
pub fn raw_indications(&self) -> Result<Receiver<Message>, Error>
pub fn raw_indications(&self) -> Result<Receiver<Message>, Error>
Subscribes to every indication, without filtering or decoding them.
Only indications received after this call are delivered. The receiver closes when the connection stops.
§Example
use ql_qmi::RawClient;
use tokio::sync::broadcast::error::RecvError;
let (client, connection) = RawClient::builder(0x401, 1).connect()?;
tokio::spawn(connection.run());
let mut indications = client.raw_indications()?;
loop {
match indications.recv().await {
Ok(indication) => println!("{:#06x}: {indication:?}", indication.msg_id()),
Err(RecvError::Lagged(missed)) => eprintln!("missed {missed} indications"),
Err(RecvError::Closed) => break,
}
}§Errors
Returns Error::Disconnected if the connection has stopped.
pub fn raw_request(
&self,
msg_id: u16,
tlvs: TlvWriter,
) -> RequestBuilder<'_, Message>
pub fn raw_request( &self, msg_id: u16, tlvs: TlvWriter, ) -> RequestBuilder<'_, Message>
Prepares a request from raw TLVs.
Await the returned builder to send the request. The response is returned as is, even if its status reports a failure.
pub(super) fn send(
&self,
msg_id: u16,
tlvs: TlvWriter,
timeout: Duration,
) -> Receiver<Result<Message, Error>> ⓘ
pub(super) fn send( &self, msg_id: u16, tlvs: TlvWriter, timeout: Duration, ) -> Receiver<Result<Message, Error>> ⓘ
Hands a request to the connection.
The returned receiver gets the response, or the error if the request can’t be sent.