Skip to content

Commit 3572c6c

Browse files
committed
updates
Signed-off-by: Jess Frazelle <[email protected]>
1 parent 7d6341e commit 3572c6c

File tree

6 files changed

+1147
-471
lines changed

6 files changed

+1147
-471
lines changed

bambulabs/src/client.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use tokio::sync::Mutex;
88

99
use crate::{
1010
command::Command,
11-
message::{Message, Print, PrintCommand},
11+
message::{Message, Print, PushStatus},
1212
parser::parse_message,
1313
sequence_id::SequenceId,
1414
};
@@ -87,11 +87,9 @@ impl Client {
8787

8888
if let Some(sequence_id) = message.sequence_id() {
8989
// If the message is a push status, make the sequence id "status".
90-
if let Message::Print(msg) = &message {
91-
if msg.command == PrintCommand::PushStatus {
92-
self.responses.insert(SequenceId::status(), message);
93-
return Ok(());
94-
}
90+
if let Message::Print(Print::PushStatus(_)) = &message {
91+
self.responses.insert(SequenceId::status(), message);
92+
return Ok(());
9593
}
9694
self.responses.insert(sequence_id, message);
9795
return Ok(());
@@ -107,11 +105,11 @@ impl Client {
107105
}
108106

109107
/// Get the latest status of the printer.
110-
pub fn get_status(&self) -> Result<Option<Print>> {
108+
pub fn get_status(&self) -> Result<Option<PushStatus>> {
111109
let response = self.responses.get(&SequenceId::status());
112110
if let Some(response) = response {
113-
if let Message::Print(print) = response.value() {
114-
return Ok(Some(print.clone()));
111+
if let Message::Print(Print::PushStatus(status)) = response.value() {
112+
return Ok(Some(status.clone()));
115113
}
116114
}
117115

bambulabs/src/command.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! The commands that can be sent to the printer.
22
33
use parse_display::{Display, FromStr};
4+
use schemars::JsonSchema;
45
use serde::{Deserialize, Serialize};
56

67
use crate::{sequence_id::SequenceId, speedprofile::SpeedProfile};
@@ -330,7 +331,7 @@ pub struct Ledctrl {
330331
}
331332

332333
/// The node for the led.
333-
#[derive(Debug, Clone, Serialize, Deserialize, Display, FromStr, PartialEq, Eq)]
334+
#[derive(Debug, Clone, Serialize, Deserialize, Display, FromStr, PartialEq, Eq, JsonSchema)]
334335
#[display(style = "snake_case")]
335336
#[serde(rename_all = "snake_case")]
336337
pub enum LedNode {
@@ -341,7 +342,7 @@ pub enum LedNode {
341342
}
342343

343344
/// The mode for the led.
344-
#[derive(Debug, Clone, Serialize, Deserialize, Display, FromStr, PartialEq, Eq)]
345+
#[derive(Debug, Clone, Serialize, Deserialize, Display, FromStr, PartialEq, Eq, JsonSchema)]
345346
#[display(style = "snake_case")]
346347
#[serde(rename_all = "snake_case")]
347348
pub enum LedMode {
@@ -391,7 +392,7 @@ pub struct GetAccessories {
391392
}
392393

393394
/// The type of accessory.
394-
#[derive(Debug, Clone, Serialize, Deserialize, Display, FromStr, PartialEq, Eq)]
395+
#[derive(Debug, Clone, Serialize, Deserialize, Display, FromStr, PartialEq, Eq, JsonSchema)]
395396
#[display(style = "snake_case")]
396397
#[serde(rename_all = "snake_case")]
397398
pub enum AccessoryType {

0 commit comments

Comments
 (0)