Skip to content

Commit ffe61aa

Browse files
fix PR comments
1 parent 049949a commit ffe61aa

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

crates/wave/src/core/decode.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ use wasm_wave::wasm::{WasmType, WasmTypeKind, WasmValue as _};
3333

3434
/// Read a wasm-wave `Value` from an async reader
3535
///
36-
/// This mirrors `wrpc_runtime_wasmtime::codec::read_value` but without the
37-
/// `Index<R>` trait bound and `path` parameter, since wasm-wave doesn't support resources.
36+
/// This mirrors `wrpc_runtime_wasmtime::codec::read_value`
37+
/// but without the `Index<R>` trait bound and `path` parameter,
38+
/// since wasm-wave doesn't support resources, async or streams
3839
///
3940
/// # Errors
4041
///
@@ -158,7 +159,7 @@ where
158159
})?;
159160

160161
let payload = if let Some(payload_type) = payload_type {
161-
let value = Box::pin(read_value(r, &payload_type)).await?;
162+
let value = Box::pin(read_value(r, payload_type)).await?;
162163
Some(value)
163164
} else {
164165
None
@@ -222,7 +223,7 @@ where
222223
}
223224
WasmTypeKind::Flags => {
224225
let names: Vec<_> = ty.flags_names().collect();
225-
let byte_count = (names.len() + 7) / 8; // Ceiling division
226+
let byte_count = names.len().div_ceil(8);
226227

227228
let mut buf = vec![0u8; byte_count];
228229
r.read_exact(&mut buf).await?;

crates/wave/src/core/encode.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ where
241241
.flatten()
242242
.context("variant case should have payload type")?;
243243
let mut enc = self.with_type(&payload_type);
244-
enc.encode(&payload_val.into_owned(), dst)
244+
enc.encode(&*payload_val, dst)
245245
.context("failed to encode variant payload")?;
246246
}
247247
Ok(())
@@ -293,7 +293,7 @@ where
293293
.option_some_type()
294294
.context("option type should have some type")?;
295295
let mut enc = self.with_type(&inner_type);
296-
enc.encode(&inner.into_owned(), dst)
296+
enc.encode(&*inner, dst)
297297
.context("failed to encode `option::some` value")?;
298298
Ok(())
299299
}
@@ -311,7 +311,7 @@ where
311311
dst.put_u8(0);
312312
if let Some(ok_ty) = ok_type {
313313
let mut enc = self.with_type(&ok_ty);
314-
enc.encode(&val.into_owned(), dst)
314+
enc.encode(&*val, dst)
315315
.context("failed to encode `result::ok` value")?;
316316
}
317317
}
@@ -329,7 +329,7 @@ where
329329
dst.put_u8(1);
330330
if let Some(err_ty) = err_type {
331331
let mut enc = self.with_type(&err_ty);
332-
enc.encode(&val.into_owned(), dst)
332+
enc.encode(&*val, dst)
333333
.context("failed to encode `result::err` value")?;
334334
}
335335
}

crates/wave/src/sync/decode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//!
1313
//! Note: `unpack` is not supported, as
1414
//! 1. `wasm-wave` doesn't't expose (`pub(super)`) its internal type system,
15-
//! so it can't be used a generic passed to `unpack<T>`
15+
//! so it can't be used a generic passed to `unpack<T>`
1616
//! 2. `unpack` only accepts one argument (`buf`)
1717
//! but, because of (1), we need to be able to pass a `Type` to decode
1818

0 commit comments

Comments
 (0)