Skip to main content

Onboard

Struct Onboard 

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

Finding a server, connecting to it, and staying let in.

Implementations§

Source§

impl Onboard

Source

pub fn seek( find: impl FnOnce() -> Option<Server> + Send + 'static, credentials: Arc<dyn Credentials>, trust: Trust, human_name: &'static str, permissions: Permissions, log_prefix: &'static str, wake: impl Fn() + Send + Sync + 'static, ) -> Self

Starts looking for the server. Returns at once: find runs on a thread of its own, because discovery can take several seconds and a name lookup can hang.

credentials is where a token, this device’s own name and a pending request are kept – see Credentials’s own doc. human_name is what an administrator sees in the device list’s own description column, e.g. "AIS target list". log_prefix tags this application’s own log lines, e.g. "ais-list". wake is passed to every Connection this opens – see Connection::open for what it is for.

How the link is doing.

Source

pub fn server(&self) -> Option<&Server>

The server this run found, once discovery has answered.

Source

pub fn trust(&self) -> &Trust

The authority this run trusts – for a caller making its own REST calls (fetching display units, say) against the same server this opened its stream to, rather than reloading it from disk again.

Source

pub fn stage(&self) -> Stage

Where this device stands. See Stage’s own doc for why this stops answering Stage::Onboarding once the link has ever come up.

Source

pub fn poll(&mut self) -> Vec<Delta>

Picks up whatever has arrived since last time, and returns every delta read off the stream – own ship’s or another vessel’s, this module does not look. Everything else the stream can say (Event::Connected, Event::Disconnected, Event::Unauthorized) is acted on here and never handed out; see the module’s own doc for why.

Source

pub fn publish(&self, delta_json: String) -> Result<(), ClientError>

Queues delta_json to be sent on the wire, as-is – for an application that also publishes, not only reads.

§Errors

If there is no open connection to send it on, or the send itself fails.

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.