pub struct Client { /* private fields */ }Expand description
A typed client of one printobserver supervisor.
One method per public operation that supervisor serves, each generated from the same checked-in description the server’s own routes are folded out of.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(address: impl AsRef<str>, actor: Actor) -> Self
pub fn new(address: impl AsRef<str>, actor: Actor) -> Self
A client of the supervisor at one address, acting as one actor.
The address is taken as the supervisor’s own configuration writes it —
http://127.0.0.1:8420 — and a bare host:port is taken as well.
Sourcepub fn with_credential(self, credential: impl Into<String>) -> Self
pub fn with_credential(self, credential: impl Into<String>) -> Self
The same client, authenticating with one credential.
The supervisor serves no versioned operation to a caller that does not
present a credential it admits — the operator’s, whose verifier it is
configured with and which printobserver credential issue issues, or the
one a supervision turn is handed — and a call it refuses for that arrives
as ClientError::Refused under status 401. A call whose actor is not
the identity that credential is arrives under status 403.
Sourcepub fn call<T: DeserializeOwned>(
&self,
method: &str,
path: &str,
query: &[(String, String)],
body: Option<&Value>,
) -> Result<T, ClientError>
pub fn call<T: DeserializeOwned>( &self, method: &str, path: &str, query: &[(String, String)], body: Option<&Value>, ) -> Result<T, ClientError>
Make one call and read what came back.
§Errors
Returns ClientError for each of the five ways a call ends other
than with its answer; a refused action arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Source§impl Client
impl Client
Sourcepub fn prints(&self) -> Result<PrintsAnswer, ClientError>
pub fn prints(&self) -> Result<PrintsAnswer, ClientError>
Call prints on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read.
Sourcepub fn status(&self, print_id: &str) -> Result<StatusAnswer, ClientError>
pub fn status(&self, print_id: &str) -> Result<StatusAnswer, ClientError>
Call status on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read.
Sourcepub fn context(&self, print_id: &str) -> Result<ContextAnswer, ClientError>
pub fn context(&self, print_id: &str) -> Result<ContextAnswer, ClientError>
Call context on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read.
Sourcepub fn image(&self, image_id: &str) -> Result<ImageAnswer, ClientError>
pub fn image(&self, image_id: &str) -> Result<ImageAnswer, ClientError>
Call image on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read.
Sourcepub fn history(
&self,
print_id: &str,
limit: Option<i64>,
) -> Result<HistoryAnswer, ClientError>
pub fn history( &self, print_id: &str, limit: Option<i64>, ) -> Result<HistoryAnswer, ClientError>
Call history on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read.
Sourcepub fn events(
&self,
after: Option<String>,
print_id: Option<String>,
kinds: Option<Vec<String>>,
exclude_kinds: Option<Vec<String>>,
wait_s: Option<i64>,
limit: Option<i64>,
) -> Result<EventsAnswer, ClientError>
pub fn events( &self, after: Option<String>, print_id: Option<String>, kinds: Option<Vec<String>>, exclude_kinds: Option<Vec<String>>, wait_s: Option<i64>, limit: Option<i64>, ) -> Result<EventsAnswer, ClientError>
Call events on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read.
Sourcepub fn manifest_get(
&self,
print_id: &str,
) -> Result<ManifestAnswer, ClientError>
pub fn manifest_get( &self, print_id: &str, ) -> Result<ManifestAnswer, ClientError>
Call manifest_get on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read.
Sourcepub fn look(
&self,
print_id: &str,
wait_s: Option<i64>,
) -> Result<Look, ClientError>
pub fn look( &self, print_id: &str, wait_s: Option<i64>, ) -> Result<Look, ClientError>
Call look on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read.
Sourcepub fn manifest_set(
&self,
print_id: &str,
reason: &str,
manifest: &JobManifest,
) -> Result<ManifestAnswer, ClientError>
pub fn manifest_set( &self, print_id: &str, reason: &str, manifest: &JobManifest, ) -> Result<ManifestAnswer, ClientError>
Call manifest_set on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Sourcepub fn spools(
&self,
include_retired: Option<bool>,
) -> Result<SpoolsAnswer, ClientError>
pub fn spools( &self, include_retired: Option<bool>, ) -> Result<SpoolsAnswer, ClientError>
Call spools on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read.
Sourcepub fn spool(&self, spool_id: &str) -> Result<SpoolAnswer, ClientError>
pub fn spool(&self, spool_id: &str) -> Result<SpoolAnswer, ClientError>
Call spool on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read.
Sourcepub fn printer_history(
&self,
kinds: Option<Vec<String>>,
since: Option<String>,
until: Option<String>,
spool_id: Option<String>,
before: Option<String>,
limit: Option<i64>,
) -> Result<TimelineAnswer, ClientError>
pub fn printer_history( &self, kinds: Option<Vec<String>>, since: Option<String>, until: Option<String>, spool_id: Option<String>, before: Option<String>, limit: Option<i64>, ) -> Result<TimelineAnswer, ClientError>
Call printer_history on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read.
Sourcepub fn preflight(&self, file_name: &str) -> Result<PreflightAnswer, ClientError>
pub fn preflight(&self, file_name: &str) -> Result<PreflightAnswer, ClientError>
Call preflight on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read.
Sourcepub fn pause(
&self,
print_id: &str,
reason: &str,
) -> Result<ActionAnswer, ClientError>
pub fn pause( &self, print_id: &str, reason: &str, ) -> Result<ActionAnswer, ClientError>
Call pause on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Sourcepub fn resume(
&self,
print_id: &str,
reason: &str,
) -> Result<ActionAnswer, ClientError>
pub fn resume( &self, print_id: &str, reason: &str, ) -> Result<ActionAnswer, ClientError>
Call resume on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Sourcepub fn cancel(
&self,
print_id: &str,
reason: &str,
) -> Result<ActionAnswer, ClientError>
pub fn cancel( &self, print_id: &str, reason: &str, ) -> Result<ActionAnswer, ClientError>
Call cancel on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Sourcepub fn start_print(
&self,
print_id: &str,
file_name: &FileName,
manifest: &JobManifest,
reason: &str,
override_filament_check: Option<bool>,
) -> Result<ActionAnswer, ClientError>
pub fn start_print( &self, print_id: &str, file_name: &FileName, manifest: &JobManifest, reason: &str, override_filament_check: Option<bool>, ) -> Result<ActionAnswer, ClientError>
Call start_print on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Sourcepub fn set_feedrate_factor(
&self,
print_id: &str,
factor: f64,
reason: &str,
duration_s: Option<i64>,
) -> Result<ActionAnswer, ClientError>
pub fn set_feedrate_factor( &self, print_id: &str, factor: f64, reason: &str, duration_s: Option<i64>, ) -> Result<ActionAnswer, ClientError>
Call set_feedrate_factor on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Sourcepub fn set_flowrate_factor(
&self,
print_id: &str,
factor: f64,
reason: &str,
duration_s: Option<i64>,
) -> Result<ActionAnswer, ClientError>
pub fn set_flowrate_factor( &self, print_id: &str, factor: f64, reason: &str, duration_s: Option<i64>, ) -> Result<ActionAnswer, ClientError>
Call set_flowrate_factor on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Sourcepub fn set_tool_target_c(
&self,
print_id: &str,
reason: &str,
target_c: f64,
tool: i64,
duration_s: Option<i64>,
) -> Result<ActionAnswer, ClientError>
pub fn set_tool_target_c( &self, print_id: &str, reason: &str, target_c: f64, tool: i64, duration_s: Option<i64>, ) -> Result<ActionAnswer, ClientError>
Call set_tool_target_c on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Sourcepub fn set_bed_target_c(
&self,
print_id: &str,
reason: &str,
target_c: f64,
duration_s: Option<i64>,
) -> Result<ActionAnswer, ClientError>
pub fn set_bed_target_c( &self, print_id: &str, reason: &str, target_c: f64, duration_s: Option<i64>, ) -> Result<ActionAnswer, ClientError>
Call set_bed_target_c on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Sourcepub fn set_fan_percent(
&self,
print_id: &str,
percent: f64,
reason: &str,
duration_s: Option<i64>,
) -> Result<ActionAnswer, ClientError>
pub fn set_fan_percent( &self, print_id: &str, percent: f64, reason: &str, duration_s: Option<i64>, ) -> Result<ActionAnswer, ClientError>
Call set_fan_percent on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Sourcepub fn acknowledge_failure(
&self,
print_id: &str,
disposition: &AcknowledgementDisposition,
event_id: &EventId,
reason: &str,
) -> Result<ActionAnswer, ClientError>
pub fn acknowledge_failure( &self, print_id: &str, disposition: &AcknowledgementDisposition, event_id: &EventId, reason: &str, ) -> Result<ActionAnswer, ClientError>
Call acknowledge_failure on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Sourcepub fn register_spool(
&self,
initial_g: f64,
material: &str,
name: &str,
reason: &str,
color: Option<String>,
density_g_cm3: Option<f64>,
diameter_mm: Option<f64>,
remaining_g: Option<f64>,
tare_g: Option<f64>,
) -> Result<SpoolCommandAnswer, ClientError>
pub fn register_spool( &self, initial_g: f64, material: &str, name: &str, reason: &str, color: Option<String>, density_g_cm3: Option<f64>, diameter_mm: Option<f64>, remaining_g: Option<f64>, tare_g: Option<f64>, ) -> Result<SpoolCommandAnswer, ClientError>
Call register_spool on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Sourcepub fn load_spool(
&self,
spool_id: &str,
reason: &str,
tool: i64,
) -> Result<SpoolCommandAnswer, ClientError>
pub fn load_spool( &self, spool_id: &str, reason: &str, tool: i64, ) -> Result<SpoolCommandAnswer, ClientError>
Call load_spool on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Sourcepub fn unload_spool(
&self,
spool_id: &str,
reason: &str,
) -> Result<SpoolCommandAnswer, ClientError>
pub fn unload_spool( &self, spool_id: &str, reason: &str, ) -> Result<SpoolCommandAnswer, ClientError>
Call unload_spool on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Sourcepub fn adjust_spool(
&self,
spool_id: &str,
reason: &str,
gross_g: Option<f64>,
remaining_g: Option<f64>,
) -> Result<SpoolCommandAnswer, ClientError>
pub fn adjust_spool( &self, spool_id: &str, reason: &str, gross_g: Option<f64>, remaining_g: Option<f64>, ) -> Result<SpoolCommandAnswer, ClientError>
Call adjust_spool on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.
Sourcepub fn retire_spool(
&self,
spool_id: &str,
reason: &str,
) -> Result<SpoolCommandAnswer, ClientError>
pub fn retire_spool( &self, spool_id: &str, reason: &str, ) -> Result<SpoolCommandAnswer, ClientError>
Call retire_spool on the configured supervisor.
§Errors
Returns ClientError when the supervisor could not be reached, when
it answered something this client cannot read, when this client
refuses the call before making it because the reason is empty, and
when the policy refused the action — which arrives as
ClientError::Rejected, carrying the reason, the value asked for and
the range allowed.