Skip to content

Commit c7f15ae

Browse files
authored
Merge pull request #14 from ProjectLighthouseCAU/stop-guard
Stop streams automatically once dropped and make path params more generic
2 parents f5f37fb + 480dfd9 commit c7f15ae

File tree

11 files changed

+101
-52
lines changed

11 files changed

+101
-52
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ default-members = ["lighthouse-client"]
77
resolver = "2"
88

99
[workspace.package]
10-
version = "3.4.0"
10+
version = "3.4.1"
1111
edition = "2021"
1212
license = "MIT"
1313

1414
[workspace.dependencies]
15-
lighthouse-protocol = { version = "^3.4.0", path = "lighthouse-protocol" }
15+
lighthouse-protocol = { version = "^3.4.1", path = "lighthouse-protocol" }

lighthouse-client/examples/admin_crud.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clap::Parser;
22
use lighthouse_client::{protocol::Authentication, Error, Lighthouse, Result, TokioWebSocket, LIGHTHOUSE_URL};
33
use tracing::{info, info_span, Instrument};
44

5-
async fn run(mut lh: Lighthouse<TokioWebSocket>) -> Result<()> {
5+
async fn run(lh: Lighthouse<TokioWebSocket>) -> Result<()> {
66
info!("Connected to the Lighthouse server");
77

88
async {

lighthouse-client/examples/admin_get_metrics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clap::Parser;
22
use lighthouse_client::{protocol::Authentication, Lighthouse, Result, TokioWebSocket, LIGHTHOUSE_URL};
33
use tracing::info;
44

5-
async fn run(mut lh: Lighthouse<TokioWebSocket>) -> Result<()> {
5+
async fn run(lh: Lighthouse<TokioWebSocket>) -> Result<()> {
66
info!("Connected to the Lighthouse server");
77

88
let metrics = lh.get_laser_metrics().await?.payload;

lighthouse-client/examples/admin_list_root.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use clap::Parser;
2-
use lighthouse_client::{protocol::Authentication, Lighthouse, Result, TokioWebSocket, LIGHTHOUSE_URL};
2+
use lighthouse_client::{protocol::Authentication, root, Lighthouse, Result, TokioWebSocket, LIGHTHOUSE_URL};
33
use tracing::info;
44

5-
async fn run(mut lh: Lighthouse<TokioWebSocket>) -> Result<()> {
5+
async fn run(lh: Lighthouse<TokioWebSocket>) -> Result<()> {
66
info!("Connected to the Lighthouse server");
77

8-
let tree = lh.list(&[]).await?.payload;
8+
let tree = lh.list(root![]).await?.payload;
99
info!("Got {}", tree);
1010

1111
Ok(())

lighthouse-client/examples/black.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clap::Parser;
22
use lighthouse_client::{protocol::{Authentication, Color, Frame}, Lighthouse, Result, TokioWebSocket, LIGHTHOUSE_URL};
33
use tracing::info;
44

5-
async fn run(mut lh: Lighthouse<TokioWebSocket>) -> Result<()> {
5+
async fn run(lh: Lighthouse<TokioWebSocket>) -> Result<()> {
66
info!("Connected to the Lighthouse server");
77

88
lh.put_model(Frame::fill(Color::BLACK)).await?;

lighthouse-client/examples/disco.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use tracing::info;
44
use tokio::time;
55
use std::time::Duration;
66

7-
async fn run(mut lh: Lighthouse<TokioWebSocket>) -> Result<()> {
7+
async fn run(lh: Lighthouse<TokioWebSocket>) -> Result<()> {
88
info!("Connected to the Lighthouse server");
99

1010
loop {

lighthouse-client/examples/input_events.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use lighthouse_client::{protocol::Authentication, Lighthouse, Result, TokioWebSo
44
use lighthouse_protocol::Model;
55
use tracing::info;
66

7-
async fn run(mut lh: Lighthouse<TokioWebSocket>) -> Result<()> {
7+
async fn run(lh: Lighthouse<TokioWebSocket>) -> Result<()> {
88
info!("Connected to the Lighthouse server");
99

1010
// Stream input events

lighthouse-client/examples/snake.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl State {
124124
}
125125
}
126126

127-
async fn run_updater(mut lh: Lighthouse<TokioWebSocket>, shared_state: Arc<Mutex<State>>) -> Result<()> {
127+
async fn run_updater(lh: Lighthouse<TokioWebSocket>, shared_state: Arc<Mutex<State>>) -> Result<()> {
128128
loop {
129129
// Update the snake and render it
130130
let frame = {
@@ -190,7 +190,7 @@ async fn main() -> Result<()> {
190190
let auth = Authentication::new(&args.username, &args.token);
191191
let state = Arc::new(Mutex::new(State::new()));
192192

193-
let mut lh = Lighthouse::connect_with_tokio_to(&args.url, auth).await?;
193+
let lh = Lighthouse::connect_with_tokio_to(&args.url, auth).await?;
194194
info!("Connected to the Lighthouse server");
195195

196196
let stream = lh.stream_model().await?;

lighthouse-client/examples/stress_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use lighthouse_client::{protocol::{Authentication, Frame}, Lighthouse, Result, T
55
use tokio::time::{self, Instant};
66
use tracing::info;
77

8-
async fn run(mut lh: Lighthouse<TokioWebSocket>, delay_ms: Option<u64>) -> Result<()> {
8+
async fn run(lh: Lighthouse<TokioWebSocket>, delay_ms: Option<u64>) -> Result<()> {
99
info!("Connected to the Lighthouse server");
1010

1111
let mut last_second = Instant::now();

lighthouse-client/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ pub use lighthouse::*;
1313
pub use spawn::*;
1414

1515
pub use lighthouse_protocol as protocol;
16+
17+
/// Small convenience macro that expresses the root path.
18+
#[macro_export]
19+
macro_rules! root {
20+
() => {
21+
&[] as &[&str]
22+
};
23+
}

0 commit comments

Comments
 (0)