Skip to main content

MessageStore

Trait MessageStore 

Source
pub trait MessageStore {
    // Required methods
    fn push(&mut self, entry: &QueuedCall) -> Result<Seq, StoreError>;
    fn pending(&self) -> Result<Vec<(Seq, QueuedCall)>, StoreError>;
    fn ack(&mut self, seq: Seq) -> Result<(), StoreError>;
    fn set_attempts(
        &mut self,
        seq: Seq,
        attempts: u32,
    ) -> Result<(), StoreError>;
    fn len(&self) -> Result<usize, StoreError>;

    // Provided method
    fn is_empty(&self) -> Result<bool, StoreError> { ... }
}
Expand description

Durable storage for transaction-related messages.

A Charging Station must survive a power cut with its queued TransactionEvents intact and replay them in order (E04.FR.01–03, E08.FR.05–07, E12.FR.01–02), and must be able to answer GetTransactionStatus.messagesInQueue from it. The trait is deliberately tiny and synchronous so it can sit on flash, SQLite or Postgres alike.

Required Methods§

Source

fn push(&mut self, entry: &QueuedCall) -> Result<Seq, StoreError>

Appends a message, returning its sequence number.

Source

fn pending(&self) -> Result<Vec<(Seq, QueuedCall)>, StoreError>

Every un-acknowledged message, oldest first.

Read when an engine is built, so a Charging Station replays what a power cut interrupted, and again by Engine::adopt_pending, which queues what another process pushed since.

Source

fn ack(&mut self, seq: Seq) -> Result<(), StoreError>

Removes a message that has been delivered (or definitively abandoned).

Source

fn set_attempts(&mut self, seq: Seq, attempts: u32) -> Result<(), StoreError>

Records a further transmission attempt for a message that is still queued.

Source

fn len(&self) -> Result<usize, StoreError>

How many messages are waiting.

Answers GetTransactionStatus.messagesInQueue.

Provided Methods§

Source

fn is_empty(&self) -> Result<bool, StoreError>

Whether the store is empty.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§