Skip to main content

PrintStore

Trait PrintStore 

Source
pub trait PrintStore: Send + Sync {
    // Required methods
    fn open_print(
        &self,
        provider_print_id: Option<i64>,
        file_name: Option<String>,
    ) -> BoxFuture<'_, Result<PrintRecord, StoreError>>;
    fn print(
        &self,
        print_id: PrintId,
    ) -> BoxFuture<'_, Result<Option<PrintRecord>, StoreError>>;
    fn open_prints(&self) -> BoxFuture<'_, Result<Vec<PrintRecord>, StoreError>>;
    fn prints(&self) -> BoxFuture<'_, Result<Vec<PrintRecord>, StoreError>>;
    fn attach_obico_print(
        &self,
        print_id: PrintId,
        obico_print_id: i64,
    ) -> BoxFuture<'_, Result<PrintRecord, StoreError>>;
    fn record_job_sighting(
        &self,
        print_id: PrintId,
        job_started_at: Timestamp,
        job_print_time_s: Option<i64>,
    ) -> BoxFuture<'_, Result<PrintRecord, StoreError>>;
    fn print_by_provider_id(
        &self,
        provider_print_id: i64,
    ) -> BoxFuture<'_, Result<Option<PrintRecord>, StoreError>>;
    fn end_print(
        &self,
        print_id: PrintId,
        state: PrinterState,
        ended_at: Timestamp,
        reason: String,
    ) -> BoxFuture<'_, Result<PrintRecord, StoreError>>;
    fn record_narrowing(
        &self,
        print_id: PrintId,
        narrowing: ManifestNarrowing,
    ) -> BoxFuture<'_, Result<PrintRecord, StoreError>>;
    fn put_manifest(
        &self,
        print_id: PrintId,
        manifest: JobManifest,
    ) -> BoxFuture<'_, Result<(), StoreError>>;
    fn manifest(
        &self,
        print_id: PrintId,
    ) -> BoxFuture<'_, Result<Option<JobManifest>, StoreError>>;
}
Expand description

The print record, with its manifest and the narrowings recorded on it.

Every method is asynchronous, the trait is dyn-compatible, and it is shareable across threads, because its consumers hold it behind Arc<dyn PrintStore>.

Required Methods§

Source

fn open_print( &self, provider_print_id: Option<i64>, file_name: Option<String>, ) -> BoxFuture<'_, Result<PrintRecord, StoreError>>

Open a print, minting its identifier.

Source

fn print( &self, print_id: PrintId, ) -> BoxFuture<'_, Result<Option<PrintRecord>, StoreError>>

Read one print by its identifier.

Source

fn open_prints(&self) -> BoxFuture<'_, Result<Vec<PrintRecord>, StoreError>>

Read every print with no end recorded, most recently opened first.

This is what a supervisor adopts on start: the store already binds an action to the most recently opened print with no end recorded, and without this method nothing above the store could name that print in order to say it had adopted it.

Source

fn prints(&self) -> BoxFuture<'_, Result<Vec<PrintRecord>, StoreError>>

Read every print, ended or not, most recently opened first.

This is what a caller finds a print’s identifier in: the identifier is minted here, and nothing outside the store could otherwise name it.

Source

fn attach_obico_print( &self, print_id: PrintId, obico_print_id: i64, ) -> BoxFuture<'_, Result<PrintRecord, StoreError>>

Record Obico’s own identifier on a print that carries none.

A print is opened before Obico reports on it when a caller finds the job the printer is running, and this is how the first alert about that job joins the print already open for it rather than opening a second. Recording the identifier a print already carries answers the print unchanged.

§Errors

Refuses a print that does not exist with StoreError::NotFound, and a print already carrying a different identifier with StoreError::ConstraintRefused naming prints.provider_print_id: a correlation, once recorded, is never moved to another of the provider’s prints.

Source

fn record_job_sighting( &self, print_id: PrintId, job_started_at: Timestamp, job_print_time_s: Option<i64>, ) -> BoxFuture<'_, Result<PrintRecord, StoreError>>

Record what one read of the printer saw of a print’s job.

The job’s start is set to job_started_at whatever it was, since a pause moves it (PrintRecord::job_started_at); the print’s running time is raised to job_print_time_s when that is longer than the one it carries and left alone otherwise, so that the longest the job was ever seen printing is what it carries. Absent job_print_time_s — a read that found the job paused — leaves the running time as it is.

§Errors

Refuses a print that does not exist with StoreError::NotFound.

Source

fn print_by_provider_id( &self, provider_print_id: i64, ) -> BoxFuture<'_, Result<Option<PrintRecord>, StoreError>>

Read one print by the provider’s own identifier for it.

Source

fn end_print( &self, print_id: PrintId, state: PrinterState, ended_at: Timestamp, reason: String, ) -> BoxFuture<'_, Result<PrintRecord, StoreError>>

End a print, in a terminal state, at an instant, for a reason.

Source

fn record_narrowing( &self, print_id: PrintId, narrowing: ManifestNarrowing, ) -> BoxFuture<'_, Result<PrintRecord, StoreError>>

Record that a manifest range was narrowed to the envelope’s.

Source

fn put_manifest( &self, print_id: PrintId, manifest: JobManifest, ) -> BoxFuture<'_, Result<(), StoreError>>

Store one print’s manifest.

Source

fn manifest( &self, print_id: PrintId, ) -> BoxFuture<'_, Result<Option<JobManifest>, StoreError>>

Read one print’s manifest.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§