Struct Lighthouse

Source
pub struct Lighthouse<S> { /* private fields */ }
Expand description

A connection to the lighthouse server for sending requests and receiving events.

Implementations§

Source§

impl Lighthouse<TokioWebSocket>

Source

pub async fn connect_with_tokio_to( url: &str, authentication: Authentication, ) -> Result<Self>

Connects to the lighthouse server at the given URL.

Source

pub async fn connect_with_tokio(authentication: Authentication) -> Result<Self>

Connects to the lighthouse server at the default URL.

Source§

impl<S> Lighthouse<S>
where S: Stream<Item = Result<Message>> + Sink<Message, Error = Error> + Send + 'static,

Source

pub fn new<W>(web_socket: S, authentication: Authentication) -> Result<Self>
where W: Spawner,

Connects to the lighthouse using the given credentials. Asynchronously runs a receive loop using the provided spawner.

Source

pub async fn put_model(&mut self, frame: Frame) -> Result<ServerMessage<()>>

Replaces the user’s lighthouse model with the given frame.

Source

pub async fn stream_model( &mut self, ) -> Result<impl Stream<Item = Result<ServerMessage<Model>>>>

Requests a stream of events (including key/controller events) for the user’s lighthouse model.

Source

pub async fn get_laser_metrics(&mut self) -> Result<ServerMessage<LaserMetrics>>

Fetches lamp server metrics.

Source

pub async fn post<P>( &mut self, path: &[&str], payload: P, ) -> Result<ServerMessage<()>>
where P: Serialize,

Combines PUT and CREATE. Requires CREATE and WRITE permission.

Source

pub async fn put<P>( &mut self, path: &[&str], payload: P, ) -> Result<ServerMessage<()>>
where P: Serialize,

Updates the resource at the given path with the given payload. Requires WRITE permission.

Source

pub async fn create(&mut self, path: &[&str]) -> Result<ServerMessage<()>>

Creates a resource at the given path. Requires CREATE permission.

Source

pub async fn delete(&mut self, path: &[&str]) -> Result<ServerMessage<()>>

Deletes a resource at the given path. Requires DELETE permission.

Source

pub async fn mkdir(&mut self, path: &[&str]) -> Result<ServerMessage<()>>

Creates a directory at the given path. Requires CREATE permission.

Source

pub async fn list( &mut self, path: &[&str], ) -> Result<ServerMessage<DirectoryTree>>

Lists the directory tree at the given path. Requires READ permission.

Source

pub async fn get<R>(&mut self, path: &[&str]) -> Result<ServerMessage<R>>
where R: for<'de> Deserialize<'de>,

Gets the resource at the given path. Requires READ permission.

Links the given source to the given destination path.

Unlinks the given source from the given destination path.

Source

pub async fn stop(&mut self, path: &[&str]) -> Result<ServerMessage<()>>

Stops the given stream.

Source

pub async fn perform<P, R>( &mut self, verb: &Verb, path: &[&str], payload: P, ) -> Result<ServerMessage<R>>
where P: Serialize, R: for<'de> Deserialize<'de>,

Performs a single request to the given path with the given payload.

Source

pub async fn stream<P, R>( &mut self, path: &[&str], payload: P, ) -> Result<impl Stream<Item = Result<ServerMessage<R>>>>
where P: Serialize, R: for<'de> Deserialize<'de>,

Performs a STREAM request to the given path with the given payload.

Source

pub fn authentication(&self) -> &Authentication

Fetches the credentials used to authenticate with the lighthouse.

Source

pub async fn close(&mut self) -> Result<()>

Closes the WebSocket connection gracefully with a close message. While the server will usually also handle abruptly closed connections properly, it is recommended to always close the Lighthouse.

Auto Trait Implementations§

§

impl<S> Freeze for Lighthouse<S>

§

impl<S> !RefUnwindSafe for Lighthouse<S>

§

impl<S> Send for Lighthouse<S>
where S: Send,

§

impl<S> Sync for Lighthouse<S>
where S: Send,

§

impl<S> Unpin for Lighthouse<S>

§

impl<S> !UnwindSafe for Lighthouse<S>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more