Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgb committed Aug 4, 2024
1 parent 16b6cfc commit 80d7609
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
10 changes: 3 additions & 7 deletions stateroom-wasm-host/src/wasm_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,12 @@ impl StateroomService for WasmHost {
}

fn connect(&mut self, client: ClientId, _: &impl StateroomContext) {
let message = MessageToProcess::Connect {
client: client.into(),
};
let message = MessageToProcess::Connect { client };
self.try_recv(message).unwrap();
}

fn disconnect(&mut self, client: ClientId, _: &impl StateroomContext) {
let message = MessageToProcess::Disconnect {
client: client.into(),
};
let message = MessageToProcess::Disconnect { client };
self.try_recv(message).unwrap();
}

Expand Down Expand Up @@ -157,7 +153,7 @@ impl WasmHost {
move |mut caller: Caller<'_, WasiCtx>, start: u32, len: u32| {
let memory = get_memory(&mut caller);
let message = get_u8_vec(&caller, &memory, start, len);
let message: MessageFromProcess = bincode::deserialize(&message).unwrap();
let message: MessageFromProcess = bincode::deserialize(message).unwrap();

match message {
MessageFromProcess::Message { recipient, message } => {
Expand Down
4 changes: 2 additions & 2 deletions stateroom-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ impl<S: StateroomService> WrappedStateroomService<S> {
self.state.init(&self.context);
}
MessageToProcess::Connect { client } => {
self.state.connect(client.into(), &self.context);
self.state.connect(client, &self.context);
}
MessageToProcess::Disconnect { client } => {
self.state.disconnect(client.into(), &self.context);
self.state.disconnect(client, &self.context);
}
MessageToProcess::Message { sender, message } => {
self.state.message(sender, message, &self.context);
Expand Down
24 changes: 12 additions & 12 deletions stateroom/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ impl MessagePayload {
}
}

impl Into<MessagePayload> for String {
fn into(self) -> MessagePayload {
MessagePayload::Text(self)
impl From<String> for MessagePayload {
fn from(val: String) -> Self {
MessagePayload::Text(val)
}
}

impl Into<MessagePayload> for &str {
fn into(self) -> MessagePayload {
MessagePayload::Text(self.to_string())
impl From<&str> for MessagePayload {
fn from(val: &str) -> Self {
MessagePayload::Text(val.to_string())
}
}

impl Into<MessagePayload> for Vec<u8> {
fn into(self) -> MessagePayload {
MessagePayload::Bytes(self)
impl From<Vec<u8>> for MessagePayload {
fn from(val: Vec<u8>) -> Self {
MessagePayload::Bytes(val)
}
}

impl Into<MessagePayload> for &[u8] {
fn into(self) -> MessagePayload {
MessagePayload::Bytes(self.to_vec())
impl From<&[u8]> for MessagePayload {
fn from(val: &[u8]) -> Self {
MessagePayload::Bytes(val.to_vec())
}
}

Expand Down

0 comments on commit 80d7609

Please sign in to comment.