Struct lighthouse_client::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>
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<Value>>where
P: Serialize,
pub async fn post<P>(
&mut self,
path: &[&str],
payload: P
) -> Result<ServerMessage<Value>>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<Value>>
pub async fn create(&mut self, path: &[&str]) -> Result<ServerMessage<Value>>
Creates a resource at the given path. Requires CREATE permission.
sourcepub async fn delete(&mut self, path: &[&str]) -> Result<ServerMessage<Value>>
pub async fn delete(&mut self, path: &[&str]) -> Result<ServerMessage<Value>>
Deletes a resource at the given path. Requires DELETE permission.
sourcepub async fn mkdir(&mut self, path: &[&str]) -> Result<ServerMessage<Value>>
pub async fn mkdir(&mut self, path: &[&str]) -> Result<ServerMessage<Value>>
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 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.