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
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 the write.
Sourcepub fn set_active_route(&self, route_href: &str) -> Result<(), ClientError>
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.
Sourcepub fn advance_to_next_point(&self) -> Result<(), ClientError>
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).
Sourcepub fn clear_active_route(&self) -> Result<(), ClientError>
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.