Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

A client for starting or stopping active route following on one server.

Built from what crate::stream::Connection and crate::access::request_access already needed, the same shape crate::anchor::Client/crate::resources::Client already take for the identical reason.

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 the write.

Source

pub fn set_active_route(&self, route_href: &str) -> Result<(), ClientError>

Starts following route_href (a route resource’s own href, the same string crate::resources::Client::publish_route hands back once a route exists to point at) from its first point.

Neither a starting point index nor sailing the route in reverse is exposed here, though both are real fields the Course API accepts: this covers following a route from its start, the only case this crate currently needs.

§Errors

If there is no token – a write always needs one – if the server cannot be reached, if route_href names a route the server cannot resolve, or if it refuses the write for any other reason.

Source

pub fn advance_to_next_point(&self) -> Result<(), ClientError>

Advances the active route to its own next point via PUT .../activeRoute/nextPoint with {"value": 1} – one step forward, the only direction auto-advance on arrival needs. The server recomputes both nextPoint and previousPoint from the route’s own geometry and the current pointIndex; this is why Self::set_active_route hands over an href instead of a raw position – pointIndex, reverse and the route’s own point count stay in whatever agreement the server keeps, rather than this crate walking the route client-side.

§Errors

The same as Self::set_active_route, plus a FAILED reply if no route is currently active at all (the server’s own guard, not one this client adds).

Source

pub fn clear_active_route(&self) -> Result<(), ClientError>

Stops following whatever route or destination is currently active, if any: a DELETE of the course itself, which is how the Course API defines “stop” – not a PUT of a null value, the way clearing the anchor watch is.

§Errors

The same as Self::set_active_route, minus a route to resolve.

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.