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.
This server requires none of its API callers; a credential is for a deployment that has put something in front of it that does.
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 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 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 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 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,
) -> Result<ActionAnswer, ClientError>
pub fn start_print( &self, print_id: &str, file_name: &FileName, manifest: &JobManifest, reason: &str, ) -> 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.