Skip to content

Commit 2ca312f

Browse files
committed
Fixed compiler warnings.
1 parent bbbcd67 commit 2ca312f

File tree

14 files changed

+25
-110
lines changed

14 files changed

+25
-110
lines changed

api/swimos_form/src/structural/tests/mod.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -204,36 +204,6 @@ impl<S: StructuralWritable, T: StructuralWritable> StructuralWritable for Genera
204204

205205
pub struct HeaderView<T>(pub T);
206206

207-
struct WithHeaderBody<T> {
208-
header: T,
209-
attr: T,
210-
slot: T,
211-
}
212-
213-
impl<T: StructuralWritable> StructuralWritable for WithHeaderBody<T> {
214-
fn num_attributes(&self) -> usize {
215-
2
216-
}
217-
218-
fn write_with<W: StructuralWriter>(&self, writer: W) -> Result<W::Repr, W::Error> {
219-
let mut rec_writer = writer.record(self.num_attributes())?;
220-
rec_writer = rec_writer.write_attr(Cow::Borrowed("StructuralWritable"), &self.header)?;
221-
rec_writer = rec_writer.write_attr(Cow::Borrowed("attr"), &self.attr)?;
222-
let mut body_writer = rec_writer.complete_header(RecordBodyKind::MapLike, 1)?;
223-
body_writer = body_writer.write_slot(&"slot", &self.slot)?;
224-
body_writer.done()
225-
}
226-
227-
fn write_into<W: StructuralWriter>(self, writer: W) -> Result<W::Repr, W::Error> {
228-
let mut rec_writer = writer.record(self.num_attributes())?;
229-
rec_writer = rec_writer.write_attr_into("StructuralWritable", self.header)?;
230-
rec_writer = rec_writer.write_attr_into("attr", self.attr)?;
231-
let mut body_writer = rec_writer.complete_header(RecordBodyKind::MapLike, 1)?;
232-
body_writer = body_writer.write_slot_into("slot", self.slot)?;
233-
body_writer.done()
234-
}
235-
}
236-
237207
struct WithHeaderField<T> {
238208
header: T,
239209
attr: T,

example_apps/console/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ console-views = { path = "console_views" }
2020
http = { workspace = true }
2121
rand = { workspace = true }
2222
duration-str = "0.5"
23+
thiserror = { workspace = true}
2324

2425
[target.'cfg(windows)'.dependencies]
2526
cursive = { version = "0.20", default-features = false, features = ["crossterm-backend"] }

example_apps/console/src/runtime/dummy_server.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
use std::{
1616
collections::{hash_map::Entry, BTreeMap, HashMap},
17-
net::SocketAddr,
1817
pin::pin,
1918
sync::Arc,
2019
time::Duration,
@@ -36,6 +35,7 @@ use swimos_form::Form;
3635
use swimos_messages::warp::{peel_envelope_header_str, RawEnvelope};
3736
use swimos_recon::{parser::parse_value, printer::print_recon_compact};
3837
use swimos_utilities::trigger;
38+
use thiserror::Error;
3939
use tokio::{
4040
net::{TcpListener, TcpStream},
4141
sync::{
@@ -159,7 +159,7 @@ impl Clone for LaneSpec {
159159
}
160160

161161
enum Event {
162-
NewConnection(TcpStream, SocketAddr),
162+
NewConnection(TcpStream),
163163
TaskDone(Result<(), TaskError>),
164164
}
165165

@@ -190,7 +190,7 @@ impl DummyServer {
190190
_ = &mut stop_rx => break,
191191
result = listener.accept() => {
192192
match result {
193-
Ok((stream, bound_to)) => Event::NewConnection(stream, bound_to),
193+
Ok((stream, _)) => Event::NewConnection(stream),
194194
Err(err) => {
195195
use std::io;
196196
match err.kind() {
@@ -215,7 +215,7 @@ impl DummyServer {
215215
}
216216
};
217217
match event {
218-
Event::NewConnection(stream, _) => {
218+
Event::NewConnection(stream) => {
219219
let subprotocols = ProtocolRegistry::new(vec!["warp0"]).unwrap();
220220
let upgrader = ratchet::accept_with(
221221
stream,
@@ -245,12 +245,17 @@ impl DummyServer {
245245
}
246246
}
247247

248-
#[derive(Debug)]
248+
#[derive(Error, Debug)]
249249
enum TaskError {
250+
#[error("A web socket error occurred: {0}")]
250251
Ws(ratchet::Error),
252+
#[error("Failed to accept an incoming connection: {0}")]
251253
AcceptErr(std::io::ErrorKind),
254+
#[error("Received a binary web socket frame.")]
252255
BadMessageType,
256+
#[error("Received a web socket frame containing invalid UTF-8.")]
253257
BadUtf8,
258+
#[error("Received an invalid Warp envelope: {0}")]
254259
BadEnvelope(String),
255260
}
256261

runtime/swimos_remote/src/task/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,17 @@ enum OutgoingEvent {
177177
Response(BytesResponseMessage),
178178
}
179179

180-
#[derive(Debug)]
180+
#[derive(Error, Debug)]
181181
enum InputError {
182+
#[error("A web socket error occurred: {0}")]
182183
WsError(ratchet::Error),
184+
#[error("A binary web socket frame was received.")]
183185
BinaryFrame,
186+
#[error("A web socket frame contained invalid UTF-8: {0}")]
184187
BadUtf8(Utf8Error),
188+
#[error("A web socket frame did not contain a valid Warp envelope: {0}")]
185189
InvalidEnvelope(MessageExtractError),
190+
#[error("The web socket connection was closed.")]
186191
Closed(Option<CloseReason>),
187192
}
188193

server/swimos_agent/src/agent_model/tests/run_handler.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,11 @@ use swimos_utilities::routing::route_uri::RouteUri;
2626
use crate::{
2727
agent_lifecycle::item_event::ItemEvent,
2828
agent_model::run_handler,
29-
event_handler::{
30-
ActionContext, HandlerAction, HandlerFuture, Modification, Spawner, StepResult,
31-
},
29+
event_handler::{ActionContext, HandlerAction, Modification, StepResult},
3230
meta::AgentMetadata,
3331
test_context::dummy_context,
3432
};
3533

36-
struct NoSpawn;
37-
38-
impl<Context> Spawner<Context> for NoSpawn {
39-
fn spawn_suspend(&self, _: HandlerFuture<Context>) {
40-
panic!("No suspended futures expected.");
41-
}
42-
}
43-
4434
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4535
enum Lane {
4636
A,

server/swimos_agent/src/event_handler/suspend/tests.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use swimos_api::agent::AgentConfig;
2828
use swimos_utilities::{routing::route_uri::RouteUri, trigger};
2929
use tokio::{sync::mpsc, time::Instant};
3030

31-
use super::{HandlerFuture, Spawner, Suspend};
31+
use super::{HandlerFuture, Suspend};
3232

3333
const CONFIG: AgentConfig = AgentConfig::DEFAULT;
3434
const NODE_URI: &str = "/node";
@@ -44,14 +44,6 @@ fn make_meta<'a>(
4444
AgentMetadata::new(uri, route_params, &CONFIG)
4545
}
4646

47-
struct NoSpawn;
48-
49-
impl<Context> Spawner<Context> for NoSpawn {
50-
fn spawn_suspend(&self, _: HandlerFuture<Context>) {
51-
panic!("No suspended futures expected.");
52-
}
53-
}
54-
5547
struct DummyAgent;
5648

5749
#[tokio::test]

server/swimos_agent/src/event_handler/tests.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ use crate::{
3232
test_context::dummy_context,
3333
};
3434

35-
use super::{
36-
join, ActionContext, Decode, HandlerAction, HandlerFuture, Modification, SideEffect, Spawner,
37-
StepResult,
38-
};
35+
use super::{join, ActionContext, Decode, HandlerAction, Modification, SideEffect, StepResult};
3936

4037
const CONFIG: AgentConfig = AgentConfig::DEFAULT;
4138
const NODE_URI: &str = "/node";
@@ -51,14 +48,6 @@ fn make_meta<'a>(
5148
AgentMetadata::new(uri, route_params, &CONFIG)
5249
}
5350

54-
struct NoSpawn;
55-
56-
impl<Context> Spawner<Context> for NoSpawn {
57-
fn spawn_suspend(&self, _: HandlerFuture<Context>) {
58-
panic!("No suspended futures expected.");
59-
}
60-
}
61-
6251
struct DummyAgent;
6352

6453
const DUMMY: DummyAgent = DummyAgent;

server/swimos_agent/src/event_queue/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ where
116116
EventQueue::push(self, action)
117117
}
118118

119-
fn is_empty(&self) -> bool {
120-
EventQueue::is_empty(self)
121-
}
122-
123119
type Output<'a> = StoreResponse<MapOperation<K, &'a V>>
124120
where
125121
Self: 'a,

server/swimos_agent/src/lanes/command/tests.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ use tokio_util::codec::Decoder;
2525
use crate::{
2626
agent_model::WriteResult,
2727
event_handler::{
28-
check_step::check_is_complete, EventHandlerError, HandlerAction, HandlerFuture,
29-
ModificationFlags, Spawner, StepResult,
28+
check_step::check_is_complete, EventHandlerError, HandlerAction, ModificationFlags,
29+
StepResult,
3030
},
3131
lanes::{command::DoCommand, LaneItem},
3232
meta::AgentMetadata,
@@ -37,14 +37,6 @@ use super::CommandLane;
3737

3838
const LANE_ID: u64 = 38;
3939

40-
struct NoSpawn;
41-
42-
impl<Context> Spawner<Context> for NoSpawn {
43-
fn spawn_suspend(&self, _: HandlerFuture<Context>) {
44-
panic!("No suspended futures expected.");
45-
}
46-
}
47-
4840
#[test]
4941
fn send_command() {
5042
let lane = CommandLane::<i32>::new(LANE_ID);

server/swimos_agent/src/lanes/map/tests.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ use uuid::Uuid;
3131

3232
use crate::{
3333
agent_model::WriteResult,
34-
event_handler::{
35-
EventHandlerError, HandlerAction, HandlerFuture, Modification, Spawner, StepResult,
36-
},
34+
event_handler::{EventHandlerError, HandlerAction, Modification, StepResult},
3735
item::MapItem,
3836
lanes::{
3937
map::{
@@ -65,14 +63,6 @@ fn init() -> HashMap<i32, Text> {
6563
.collect()
6664
}
6765

68-
struct NoSpawn;
69-
70-
impl<Context> Spawner<Context> for NoSpawn {
71-
fn spawn_suspend(&self, _: HandlerFuture<Context>) {
72-
panic!("No suspended futures expected.");
73-
}
74-
}
75-
7666
#[test]
7767
fn get_from_map_lane() {
7868
let lane = MapLane::new(ID, init());

0 commit comments

Comments
 (0)