pub struct Client { /* private fields */ }Expand description
A client for one server’s own Resources API.
Built from what crate::stream::Connection and
crate::access::request_access already needed – the server’s own
HTTP base, which authority to trust, and (once one exists) the
device’s own token – rather than a new set of credentials this
module invents for itself.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(http_base: String, trust: Trust, token: Option<String>) -> Self
pub fn new(http_base: String, trust: Trust, token: Option<String>) -> Self
A client for the server at http_base, using trust to decide
which server may answer and token (once one exists) to
authenticate writes.
Sourcepub fn list_waypoints(&self) -> Result<Vec<Waypoint>, ClientError>
pub fn list_waypoints(&self) -> Result<Vec<Waypoint>, ClientError>
Every waypoint the server currently holds.
§Errors
If the server cannot be reached, or answers something this cannot make sense of.
Sourcepub fn publish_waypoint(
&self,
waypoint: &Waypoint,
) -> Result<String, ClientError>
pub fn publish_waypoint( &self, waypoint: &Waypoint, ) -> Result<String, ClientError>
Creates a new waypoint (waypoint.uuid is None) or replaces one
at its own known id (Some). Either way, answers the id the
waypoint now has on the server.
§Errors
If there is no token – a write always needs one – if the server cannot be reached, or if it refuses the write.
Sourcepub fn delete_waypoint(&self, uuid: &str) -> Result<(), ClientError>
pub fn delete_waypoint(&self, uuid: &str) -> Result<(), ClientError>
Deletes a waypoint by id.
§Errors
If there is no token – a write always needs one, the same as
Client::publish_waypoint – if the server cannot be reached,
or if it refuses the delete.
Sourcepub fn list_routes(&self) -> Result<Vec<Route>, ClientError>
pub fn list_routes(&self) -> Result<Vec<Route>, ClientError>
Every route the server currently holds.
§Errors
If the server cannot be reached, or answers something this cannot make sense of.
Sourcepub fn publish_route(&self, route: &Route) -> Result<String, ClientError>
pub fn publish_route(&self, route: &Route) -> Result<String, ClientError>
Creates a new route (route.uuid is None) or replaces one at
its own known id (Some). Either way, answers the id the route
now has on the server.
§Errors
If there is no token – a write always needs one – if the server cannot be reached, or if it refuses the write.
Sourcepub fn delete_route(&self, uuid: &str) -> Result<(), ClientError>
pub fn delete_route(&self, uuid: &str) -> Result<(), ClientError>
Deletes a route by id.
§Errors
If there is no token – a write always needs one, the same as
Client::publish_route – if the server cannot be reached, or
if it refuses the delete.
Sourcepub fn list_tracks(&self) -> Result<Vec<Track>, ClientError>
pub fn list_tracks(&self) -> Result<Vec<Track>, ClientError>
Every track the server currently holds. See Client::list_routes’s
own doc for the identical shape; the only difference is the path.
§Errors
If the server cannot be reached, or it refuses the read –
including a server whose tracks custom collection was never
enabled at all, see Track’s own doc.
Sourcepub fn publish_track(&self, track: &Track) -> Result<String, ClientError>
pub fn publish_track(&self, track: &Track) -> Result<String, ClientError>
Creates a new track (track.uuid is None) or replaces one at
its own known id (Some). Either way, answers the id the track
now has on the server. See Client::publish_route’s own doc
for the identical shape; the only difference is the path.
§Errors
If there is no token – a write always needs one – if the server
cannot be reached, or if it refuses the write (including a
server whose tracks custom collection was never enabled at
all, see Track’s own doc).
Sourcepub fn delete_track(&self, uuid: &str) -> Result<(), ClientError>
pub fn delete_track(&self, uuid: &str) -> Result<(), ClientError>
Deletes a track by id. See Client::delete_route’s own doc for
the identical shape; the only difference is the path.
§Errors
If there is no token – a write always needs one, the same as
Client::publish_track – if the server cannot be reached, or
if it refuses the delete.