Skip to main content

Client

Struct Client 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.