pub struct LanMqttClient { /* private fields */ }Expand description
A one-shot LAN MQTT client.
Implementations§
Source§impl LanMqttClient
impl LanMqttClient
pub fn new(target: ResolvedTarget) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Sourcepub fn fetch_version(&self) -> Result<DeviceVersion, ClientError>
pub fn fetch_version(&self) -> Result<DeviceVersion, ClientError>
Fetch the printer’s module/firmware inventory (info.get_version).
Sourcepub fn watch<F: FnMut(&ReportState) -> WatchStep>(
&self,
interval: Option<Duration>,
on_update: F,
) -> Result<ReportState, ClientError>
pub fn watch<F: FnMut(&ReportState) -> WatchStep>( &self, interval: Option<Duration>, on_update: F, ) -> Result<ReportState, ClientError>
Watch a job to completion: invoke on_update on every merged report
until it returns WatchStep::Stop, or the total timeout elapses
(fail-fast — a dropped connection errors). With interval set, also send
a periodic pushall to raise the data rate. For job start --watch.
Sourcepub fn monitor<F: FnMut(&ReportState) -> WatchStep>(
&self,
interval: Option<Duration>,
on_update: F,
) -> Result<ReportState, ClientError>
pub fn monitor<F: FnMut(&ReportState) -> WatchStep>( &self, interval: Option<Duration>, on_update: F, ) -> Result<ReportState, ClientError>
Continuously monitor: like watch but never stops on
its own and auto-reconnects through drops. timeout is a stall
window — it ends only after no report arrives for that long (reset on
every report), so a responsive printer is watched indefinitely while a
truly-gone one is dropped after the window. For status --watch.
Sourcepub fn send_and_watch<F: FnMut(&ReportState) -> WatchStep>(
&self,
commands: &[Command],
on_update: F,
) -> Result<ReportState, ClientError>
pub fn send_and_watch<F: FnMut(&ReportState) -> WatchStep>( &self, commands: &[Command], on_update: F, ) -> Result<ReportState, ClientError>
Publish commands (after the initial pushall) on a single connection,
then watch the resulting reports until on_update stops or the timeout
elapses. One connection respects the A1/P1 single-client MQTT limit.
Sourcepub fn send_and_verify(
&self,
cmd: &Command,
) -> Result<CommandOutcome, ClientError>
pub fn send_and_verify( &self, cmd: &Command, ) -> Result<CommandOutcome, ClientError>
Send a control command and verify it. The ACK (echoed sequence_id +
result) is necessary but not sufficient: for commands with an
observable effect we also confirm the effect in the report and watch for
a new print_error (see CommandOutcome). A verify timeout yields
CommandOutcome::Unverified — published but not confirmed — never
assume success.
Sourcepub fn send_fire(&self, cmd: &Command) -> Result<(), ClientError>
pub fn send_fire(&self, cmd: &Command) -> Result<(), ClientError>
Publish a command fire-and-forget — no ACK or effect is awaited. For
commands whose effect can’t be read back because they tear down the
connection (e.g. Command::Reboot). Returns once the publish is flushed.