pub struct Ecr17Session<T: Transport> { /* private fields */ }Expand description
Drives ECR17 exchanges over a Transport T.
Implementations§
Source§impl<T: Transport> Ecr17Session<T>
impl<T: Transport> Ecr17Session<T>
Sourcepub fn new(transport: T, config: SessionConfig) -> Self
pub fn new(transport: T, config: SessionConfig) -> Self
Creates a session over transport with config.
Sourcepub fn set_on_progress(&mut self, cb: impl Fn(String) + Send + 'static)
pub fn set_on_progress(&mut self, cb: impl Fn(String) + Send + 'static)
Sets the progress-update callback (SOH frames during a procedure).
Sourcepub fn set_on_receipt_line(&mut self, cb: impl Fn(String) + Send + 'static)
pub fn set_on_receipt_line(&mut self, cb: impl Fn(String) + Send + 'static)
Sets the receipt-line callback (S messages when ECR printing is on).
Sourcepub fn transport(&self) -> &T
pub fn transport(&self) -> &T
Borrows the underlying transport for read-only inspection (state, test counters).
To reconnect it, use transport_mut or connect.
Sourcepub fn transport_mut(&mut self) -> &mut T
pub fn transport_mut(&mut self) -> &mut T
Mutably borrows the underlying transport (e.g. to reconnect it).
Sourcepub async fn disconnect(&mut self)
pub async fn disconnect(&mut self)
Closes the transport connection.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Whether the transport currently believes it is connected.
Sourcepub async fn exchange(&mut self, request_payload: &str) -> Result<DecodedPacket>
pub async fn exchange(&mut self, request_payload: &str) -> Result<DecodedPacket>
Sends request_payload (the application message, without STX/ETX) and returns the
decoded application result. Errors on retransmission exhaustion, ACK/response
timeout, or transport disconnect.
Sourcepub async fn exchange_with_additional_data(
&mut self,
request_payload: &str,
additional_payload: &str,
) -> Result<DecodedPacket>
pub async fn exchange_with_additional_data( &mut self, request_payload: &str, additional_payload: &str, ) -> Result<DecodedPacket>
Like exchange but sends an extra additional-data message (U,
tokenization) after the main request is ACKed, before the result:
request(flag=1) -> ACK -> 'U' -> ACK -> result.
Sourcepub async fn send_ack_only(&mut self, request_payload: &str) -> Result<()>
pub async fn send_ack_only(&mut self, request_payload: &str) -> Result<()>
For commands whose only reply is the physical ACK (e.g. enable/disable ECR
printing E): performs the ACK handshake with retransmission and returns once ACK
is received; does NOT wait for an application response.