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(&self, frame: Frame) -> Result<ServerMessage<()>>

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

Source

pub async fn stream_model( &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 put_input(&self, payload: InputEvent) -> Result<ServerMessage<()>>

Sends an input event to the user’s input endpoint.

Note that this is the new API which not all clients may support.

Source

pub async fn stream_input( &self, ) -> Result<impl Stream<Item = Result<ServerMessage<InputEvent>>>>

Streams input events from the user’s input endpoint.

Note that this is the new API which not all clients may support (in LUNA disabling the legacy mode will send events to this endpoint). If your client or library does not support this, you may need to stream_model and parse LegacyInputEvents from there.

Source

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

Fetches lamp server metrics.

Source

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

Combines PUT and CREATE. Requires CREATE and WRITE permission.

Source

pub async fn put<P>( &self, path: &[impl AsRef<str> + Debug], 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( &self, path: &[impl AsRef<str> + Debug], ) -> Result<ServerMessage<()>>

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

Source

pub async fn delete( &self, path: &[impl AsRef<str> + Debug], ) -> Result<ServerMessage<()>>

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

Source

pub async fn mkdir( &self, path: &[impl AsRef<str> + Debug], ) -> Result<ServerMessage<()>>

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

Source

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

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

Source

pub async fn get<R>( &self, path: &[impl AsRef<str> + Debug], ) -> 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( &self, request_id: i32, path: &[impl AsRef<str> + Debug], ) -> Result<ServerMessage<()>>

Stops the given stream. Should generally not be called manually, since streams will automatically be stopped once dropped.

Source

pub async fn perform<P, R>( &self, verb: &Verb, path: &[impl AsRef<str> + Debug], 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>( &self, path: &[impl AsRef<str> + Debug], 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. Automatically sends a STOP once dropped.

Source

pub fn authentication(&self) -> &Authentication

Fetches the credentials used to authenticate with the lighthouse.

Source

pub async fn close(&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.

Trait Implementations§

Source§

impl<S> Clone for Lighthouse<S>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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
Source§

impl<T> ErasedDestructor for T
where T: 'static,