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(&mut self, frame: Frame) -> Result<ServerMessage<()>>
pub async fn put_model(&mut self, frame: Frame) -> Result<ServerMessage<()>>
Replaces the user’s lighthouse model with the given frame.
Sourcepub async fn stream_model(
&mut self,
) -> Result<impl Stream<Item = Result<ServerMessage<Model>>>>
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.
Sourcepub async fn get_laser_metrics(&mut self) -> Result<ServerMessage<LaserMetrics>>
pub async fn get_laser_metrics(&mut self) -> Result<ServerMessage<LaserMetrics>>
Fetches lamp server metrics.
Sourcepub async fn post<P>(
&mut self,
path: &[&str],
payload: P,
) -> Result<ServerMessage<()>>where
P: Serialize,
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.
Sourcepub async fn put<P>(
&mut self,
path: &[&str],
payload: P,
) -> Result<ServerMessage<()>>where
P: Serialize,
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.
Sourcepub async fn create(&mut self, path: &[&str]) -> Result<ServerMessage<()>>
pub async fn create(&mut self, path: &[&str]) -> Result<ServerMessage<()>>
Creates a resource at the given path. Requires CREATE permission.
Sourcepub async fn delete(&mut self, path: &[&str]) -> Result<ServerMessage<()>>
pub async fn delete(&mut self, path: &[&str]) -> Result<ServerMessage<()>>
Deletes a resource at the given path. Requires DELETE permission.
Sourcepub async fn mkdir(&mut self, path: &[&str]) -> Result<ServerMessage<()>>
pub async fn mkdir(&mut self, path: &[&str]) -> Result<ServerMessage<()>>
Creates a directory at the given path. Requires CREATE permission.
Sourcepub async fn list(
&mut self,
path: &[&str],
) -> Result<ServerMessage<DirectoryTree>>
pub async fn list( &mut self, path: &[&str], ) -> Result<ServerMessage<DirectoryTree>>
Lists the directory tree at the given path. Requires READ permission.
Sourcepub async fn get<R>(&mut self, path: &[&str]) -> Result<ServerMessage<R>>where
R: for<'de> Deserialize<'de>,
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.
Sourcepub async fn link(
&mut self,
src_path: &[&str],
dest_path: &[&str],
) -> Result<ServerMessage<()>>
pub async fn link( &mut self, src_path: &[&str], dest_path: &[&str], ) -> Result<ServerMessage<()>>
Links the given source to the given destination path.
Sourcepub async fn unlink(
&mut self,
src_path: &[&str],
dest_path: &[&str],
) -> Result<ServerMessage<()>>
pub async fn unlink( &mut self, src_path: &[&str], dest_path: &[&str], ) -> Result<ServerMessage<()>>
Unlinks the given source from the given destination path.
Sourcepub async fn stop(&mut self, path: &[&str]) -> Result<ServerMessage<()>>
pub async fn stop(&mut self, path: &[&str]) -> Result<ServerMessage<()>>
Stops the given stream.
Sourcepub async fn perform<P, R>(
&mut self,
verb: &Verb,
path: &[&str],
payload: P,
) -> Result<ServerMessage<R>>where
P: Serialize,
R: for<'de> Deserialize<'de>,
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.
Sourcepub 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>,
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.
Sourcepub fn authentication(&self) -> &Authentication
pub fn authentication(&self) -> &Authentication
Fetches the credentials used to authenticate with the lighthouse.
Sourcepub async fn close(&mut self) -> Result<()>
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.