pub struct Ecr17Client<T: Transport> { /* private fields */ }Expand description
High-level ECR17 client over a Transport T.
Implementations§
Source§impl<T: Transport> Ecr17Client<T>
impl<T: Transport> Ecr17Client<T>
Sourcepub fn new(transport: T, config: Ecr17Config) -> Self
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).
Sourcepub fn configuration(&self) -> &Ecr17Config
pub fn configuration(&self) -> &Ecr17Config
The active configuration.
Sourcepub fn set_on_progress(
&self,
cb: impl Fn(ProgressEvent) + Send + Sync + 'static,
)
pub fn set_on_progress( &self, cb: impl Fn(ProgressEvent) + Send + Sync + 'static, )
Registers the progress-update listener (SOH frames during a procedure).
Sourcepub fn set_on_receipt_line(
&self,
cb: impl Fn(ReceiptLine) + Send + Sync + 'static,
)
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).
Sourcepub fn set_on_connection_state_change(
&self,
cb: impl Fn(ConnectionState) + Send + Sync + 'static,
)
pub fn set_on_connection_state_change( &self, cb: impl Fn(ConnectionState) + Send + Sync + 'static, )
Registers the connection-state listener.
Sourcepub async fn connect(&mut self) -> Result<()>
pub async fn connect(&mut self) -> Result<()>
Opens the connection (emits Connecting → Connected/Disconnected).
Sourcepub async fn disconnect(&mut self)
pub async fn disconnect(&mut self)
Closes the connection (emits Disconnected).
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Whether the transport currently believes it is connected.
Sourcepub async fn status(&mut self) -> Result<PosStatusResponse>
pub async fn status(&mut self) -> Result<PosStatusResponse>
Status (s).
Sourcepub async fn pay(&mut self, request: &PaymentRequest) -> Result<PaymentResult>
pub async fn pay(&mut self, request: &PaymentRequest) -> Result<PaymentResult>
Payment (P).
Sourcepub async fn pay_extended(
&mut self,
request: &PaymentRequest,
) -> Result<PaymentResult>
pub async fn pay_extended( &mut self, request: &PaymentRequest, ) -> Result<PaymentResult>
Extended payment (X).
Sourcepub async fn reverse(
&mut self,
request: &ReversalRequest,
) -> Result<ReversalResult>
pub async fn reverse( &mut self, request: &ReversalRequest, ) -> Result<ReversalResult>
Reversal (S).
Sourcepub async fn pre_auth(
&mut self,
request: &PreAuthRequest,
) -> Result<PreAuthResult>
pub async fn pre_auth( &mut self, request: &PreAuthRequest, ) -> Result<PreAuthResult>
Pre-auth (p).
Sourcepub async fn incremental_auth(
&mut self,
request: &IncrementalAuthRequest,
) -> Result<PreAuthResult>
pub async fn incremental_auth( &mut self, request: &IncrementalAuthRequest, ) -> Result<PreAuthResult>
Incremental pre-auth (i).
Sourcepub async fn pre_auth_closure(
&mut self,
request: &PreAuthClosureRequest,
) -> Result<PaymentResult>
pub async fn pre_auth_closure( &mut self, request: &PreAuthClosureRequest, ) -> Result<PaymentResult>
Pre-auth closure (c).
Sourcepub async fn verify_card(
&mut self,
request: &CardVerificationRequest,
) -> Result<CardVerificationResult>
pub async fn verify_card( &mut self, request: &CardVerificationRequest, ) -> Result<CardVerificationResult>
Card verification (H).
Sourcepub async fn close_session(&mut self) -> Result<CloseSessionResult>
pub async fn close_session(&mut self) -> Result<CloseSessionResult>
Close session (C).
Sourcepub async fn totals(&mut self) -> Result<TotalsResult>
pub async fn totals(&mut self) -> Result<TotalsResult>
Totals (T).
Sourcepub async fn send_last_result(&mut self) -> Result<PaymentResult>
pub async fn send_last_result(&mut self) -> Result<PaymentResult>
Send last result (G) — recovers a lost financial response without re-charging.
Sourcepub async fn enable_ecr_printing(&mut self, enabled: bool) -> Result<()>
pub async fn enable_ecr_printing(&mut self, enabled: bool) -> Result<()>
Enable/disable ECR printing (E).
Sourcepub async fn vas(&mut self, xml_request: &str) -> Result<VasResult>
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.