Skip to main content

Crate printobserver_sdk

Crate printobserver_sdk 

Source
Expand description

printobserver-sdk.

Owns: the Rust client of the printobserver server’s HTTP surface: a typed, blocking client with one method per public operation, and the request and response types those methods take and answer.

May depend on: serde and serde_json. Never printobserver-core, never the server, and never an implementation crate — a client that could reach them would be a second copy of the server. It does not depend on printobserver-types either: its types are generated from the same checked-in schemas that crate generates, so the two agree because they come from one source rather than because one imports the other.

§The types are generated, and the gate says so

contract is written by contract-codegen from schemas/, and just check-generated refuses a tree in which it differs from what that generator writes. Everything else in this crate is the transport and the error vocabulary that module’s methods are written against.

§A refused action is an answer, not a failure of transport

The policy’s own refusal arrives as ClientError::Rejected, carrying Rejection — the reason, the value asked for and the range allowed — so a caller can ask again for something inside the range without reading a message.

§Images are a path, never bytes

No method of this client answers image bytes or an encoding of them. The server answers an absolute path on its own filesystem, and this client hands that path back exactly as it was answered.

§The reason is not something a caller can leave out

Every mutating method takes it as an argument, so a call that omits it does not compile. That is the whole of the enforcement in this client: there is no run-time refusal for an omission, because there is no way to make one.

ⓘ
use printobserver_sdk::{Actor, Client};

let client = Client::new("http://127.0.0.1:8420", Actor::Operator);
// No reason: this does not compile, which is the point.
let _ = client.pause("0198f0a1-2b3c-7d4e-8f90-123456789abc");
use printobserver_sdk::{Actor, Client};

let client = Client::new("http://127.0.0.1:8420", Actor::Operator);
let status = client.status("0198f0a1-2b3c-7d4e-8f90-123456789abc")?;
println!("{:?}", status.print.state);

Re-exports§

pub use contract::*;

Modules§

contract
Generated by contract-codegen from the checked-in contract schemas.

Structs§

Answered
What the supervisor answered.
Client
A typed client of one printobserver supervisor.
Rejection
The policy’s own refusal of one action, as a caller reads it.

Enums§

ClientError
Why a call did not answer what it asked for.

Functions§

as_value
One value a request carries, as the JSON it travels as.
reason_given
The reason a mutating call carries, refused here when it carries none.