We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
wasmi_ir2
Decoder
&[u8]
1 parent 5082b07 commit 34a082eCopy full SHA for 34a082e
crates/ir2/src/decode/mod.rs
@@ -77,6 +77,17 @@ impl fmt::Display for DecodeError {
77
}
78
79
80
+impl Decoder for &'_ [u8] {
81
+ fn read_bytes(&mut self, buffer: &mut [u8]) -> Result<(), DecodeError> {
82
+ let Some((bytes, rest)) = self.split_at_checked(buffer.len()) else {
83
+ return Err(DecodeError::OutOfBytes);
84
+ };
85
+ buffer.copy_from_slice(bytes);
86
+ *self = rest;
87
+ Ok(())
88
+ }
89
+}
90
+
91
/// Types that can be decoded using a type that implements [`Decoder`].
92
pub trait Decode: Sized {
93
/// Decodes `Self` via `decoder`.
0 commit comments