Skip to main content

Ecr17Session

Struct Ecr17Session 

Source
pub struct Ecr17Session<T: Transport> { /* private fields */ }
Expand description

Drives ECR17 exchanges over a Transport T.

Implementations§

Source§

impl<T: Transport> Ecr17Session<T>

Source

pub fn new(transport: T, config: SessionConfig) -> Self

Creates a session over transport with config.

Source

pub fn set_on_progress(&mut self, cb: impl Fn(String) + Send + 'static)

Sets the progress-update callback (SOH frames during a procedure).

Source

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).

Source

pub fn transport(&self) -> &T

Borrows the underlying transport for read-only inspection (state, test counters). To reconnect it, use transport_mut or connect.

Source

pub fn transport_mut(&mut self) -> &mut T

Mutably borrows the underlying transport (e.g. to reconnect it).

Source

pub async fn connect(&mut self) -> Result<()>

Opens the transport connection.

Source

pub async fn disconnect(&mut self)

Closes the transport connection.

Source

pub fn is_connected(&self) -> bool

Whether the transport currently believes it is connected.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<T: Transport> Debug for Ecr17Session<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Ecr17Session<T>

§

impl<T> !Sync for Ecr17Session<T>

§

impl<T> !UnwindSafe for Ecr17Session<T>

§

impl<T> Freeze for Ecr17Session<T>
where T: Freeze,

§

impl<T> Send for Ecr17Session<T>

§

impl<T> Unpin for Ecr17Session<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Ecr17Session<T>
where T: UnsafeUnpin,

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> 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, 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.