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>
impl Lighthouse<TokioWebSocket>
Sourcepub async fn connect_with_tokio_to(
url: &str,
authentication: Authentication,
) -> Result<Self>
pub async fn connect_with_tokio_to( url: &str, authentication: Authentication, ) -> Result<Self>
Connects to the lighthouse server at the given URL.
Sourcepub async fn connect_with_tokio(authentication: Authentication) -> Result<Self>
pub async fn connect_with_tokio(authentication: Authentication) -> Result<Self>
Connects to the lighthouse server at the default URL.
Source§impl<S> Lighthouse<S>
impl<S> Lighthouse<S>
Sourcepub fn new<W>(web_socket: S, authentication: Authentication) -> Result<Self>where
W: Spawner,
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.
Sourcepub async fn put_model(&self, frame: Frame) -> Result<ServerMessage<()>>
pub async fn put_model(&self, frame: Frame) -> Result<ServerMessage<()>>
Replaces the user’s lighthouse model with the given frame.
Sourcepub async fn stream_model(
&self,
) -> Result<impl Stream<Item = Result<ServerMessage<Model>>>>
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.
Sourcepub async fn put_input(&self, payload: InputEvent) -> Result<ServerMessage<()>>
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.
Sourcepub async fn stream_input(
&self,
) -> Result<impl Stream<Item = Result<ServerMessage<InputEvent>>>>
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 LegacyInputEvent
s from there.
Sourcepub async fn get_laser_metrics(&self) -> Result<ServerMessage<LaserMetrics>>
pub async fn get_laser_metrics(&self) -> Result<ServerMessage<LaserMetrics>>
Fetches lamp server metrics.
Sourcepub async fn post<P>(
&self,
path: &[impl AsRef<str> + Debug],
payload: P,
) -> Result<ServerMessage<()>>where
P: Serialize,
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.
Sourcepub async fn put<P>(
&self,
path: &[impl AsRef<str> + Debug],
payload: P,
) -> Result<ServerMessage<()>>where
P: Serialize,
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.
Sourcepub async fn create(
&self,
path: &[impl AsRef<str> + Debug],
) -> Result<ServerMessage<()>>
pub async fn create( &self, path: &[impl AsRef<str> + Debug], ) -> Result<ServerMessage<()>>
Creates a resource at the given path. Requires CREATE permission.
Sourcepub async fn delete(
&self,
path: &[impl AsRef<str> + Debug],
) -> Result<ServerMessage<()>>
pub async fn delete( &self, path: &[impl AsRef<str> + Debug], ) -> Result<ServerMessage<()>>
Deletes a resource at the given path. Requires DELETE permission.
Sourcepub async fn mkdir(
&self,
path: &[impl AsRef<str> + Debug],
) -> Result<ServerMessage<()>>
pub async fn mkdir( &self, path: &[impl AsRef<str> + Debug], ) -> Result<ServerMessage<()>>
Creates a directory at the given path. Requires CREATE permission.
Sourcepub async fn list(
&self,
path: &[impl AsRef<str> + Debug],
) -> Result<ServerMessage<DirectoryTree>>
pub async fn list( &self, path: &[impl AsRef<str> + Debug], ) -> Result<ServerMessage<DirectoryTree>>
Lists the directory tree at the given path. Requires READ permission.
Sourcepub async fn get<R>(
&self,
path: &[impl AsRef<str> + Debug],
) -> Result<ServerMessage<R>>where
R: for<'de> Deserialize<'de>,
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.
Sourcepub async fn link(
&self,
src_path: &[impl AsRef<str> + Debug],
dest_path: &[impl AsRef<str> + Debug],
) -> Result<ServerMessage<()>>
pub async fn link( &self, src_path: &[impl AsRef<str> + Debug], dest_path: &[impl AsRef<str> + Debug], ) -> Result<ServerMessage<()>>
Links the given source to the given destination path.
Sourcepub async fn unlink(
&self,
src_path: &[impl AsRef<str> + Debug],
dest_path: &[impl AsRef<str> + Debug],
) -> Result<ServerMessage<()>>
pub async fn unlink( &self, src_path: &[impl AsRef<str> + Debug], dest_path: &[impl AsRef<str> + Debug], ) -> Result<ServerMessage<()>>
Unlinks the given source from the given destination path.
Sourcepub async fn stop(
&self,
request_id: i32,
path: &[impl AsRef<str> + Debug],
) -> Result<ServerMessage<()>>
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.
Sourcepub 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>,
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.
Sourcepub 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>,
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.
Sourcepub fn authentication(&self) -> &Authentication
pub fn authentication(&self) -> &Authentication
Fetches the credentials used to authenticate with the lighthouse.
Sourcepub async fn close(&self) -> Result<()>
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
.