Skip to main content

Ecr17Client

Struct Ecr17Client 

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

High-level ECR17 client over a Transport T.

Implementations§

Source§

impl<T: Transport> Ecr17Client<T>

Source

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

Creates a client over transport with config. The transport must already target the configured host/port (it is (re)connected on demand).

Source

pub fn configuration(&self) -> &Ecr17Config

The active configuration.

Source

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

Registers the progress-update listener (SOH frames during a procedure).

Source

pub fn set_on_receipt_line( &self, cb: impl Fn(ReceiptLine) + Send + Sync + 'static, )

Registers the receipt-line listener (S messages when ECR printing is on).

Source

pub fn set_on_connection_state_change( &self, cb: impl Fn(ConnectionState) + Send + Sync + 'static, )

Registers the connection-state listener.

Source

pub fn transport(&self) -> &T

Borrows the underlying session’s transport (read-only).

Source

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

Opens the connection (emits ConnectingConnected/Disconnected).

Source

pub async fn disconnect(&mut self)

Closes the connection (emits Disconnected).

Source

pub fn is_connected(&self) -> bool

Whether the transport currently believes it is connected.

Source

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

Status (s).

Source

pub async fn pay(&mut self, request: &PaymentRequest) -> Result<PaymentResult>

Payment (P).

Source

pub async fn pay_extended( &mut self, request: &PaymentRequest, ) -> Result<PaymentResult>

Extended payment (X).

Source

pub async fn reverse( &mut self, request: &ReversalRequest, ) -> Result<ReversalResult>

Reversal (S).

Source

pub async fn pre_auth( &mut self, request: &PreAuthRequest, ) -> Result<PreAuthResult>

Pre-auth (p).

Source

pub async fn incremental_auth( &mut self, request: &IncrementalAuthRequest, ) -> Result<PreAuthResult>

Incremental pre-auth (i).

Source

pub async fn pre_auth_closure( &mut self, request: &PreAuthClosureRequest, ) -> Result<PaymentResult>

Pre-auth closure (c).

Source

pub async fn verify_card( &mut self, request: &CardVerificationRequest, ) -> Result<CardVerificationResult>

Card verification (H).

Source

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

Close session (C).

Source

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

Totals (T).

Source

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

Send last result (G) — recovers a lost financial response without re-charging.

Source

pub async fn enable_ecr_printing(&mut self, enabled: bool) -> Result<()>

Enable/disable ECR printing (E).

Source

pub async fn reprint(&mut self, to_ecr: bool) -> Result<()>

Reprint the last ticket (R).

Source

pub async fn vas(&mut self, xml_request: &str) -> Result<VasResult>

VAS (K).

Reads a single VAS response message (as the reference does). A multi-part response (more_messages set) is not concatenated here — that is a documented limitation to validate against a real terminal before implementing.

Trait Implementations§

Source§

impl<T: Transport> Debug for Ecr17Client<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 Ecr17Client<T>

§

impl<T> !Sync for Ecr17Client<T>

§

impl<T> !UnwindSafe for Ecr17Client<T>

§

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

§

impl<T> Send for Ecr17Client<T>

§

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

§

impl<T> UnsafeUnpin for Ecr17Client<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.