Skip to content

Commit 116a506

Browse files
committed
Update to zerocopy 0.8
1 parent e7989e7 commit 116a506

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

Cargo.lock

Lines changed: 5 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ serde = { version = "1.0.204", features = ["derive"], optional = true }
4949
serde_json = { version = "1.0.121", optional = true }
5050
time = "0.3.36"
5151
toml = { version = "0.8.19", optional = true }
52-
zerocopy = { version = "0.7.35", features = ["derive"] }
52+
zerocopy = { version = "0.8.14", features = ["derive"] }

src/protocol.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use embedded_graphics::{
1212
Drawable,
1313
};
1414
use time::OffsetDateTime;
15-
use zerocopy::{AsBytes, BigEndian, FromBytes, FromZeroes, U16};
15+
use zerocopy::{BigEndian, FromBytes, Immutable, IntoBytes, KnownLayout, U16};
1616

1717
/// Message style configuration
1818
/// ```
@@ -197,7 +197,7 @@ const MSG_PADDING_ALIGN: usize = 64;
197197

198198
const MAGIC: [u8; 6] = *b"wang\0\0";
199199

200-
#[derive(FromZeroes, FromBytes, AsBytes)]
200+
#[derive(FromBytes, IntoBytes, Immutable, KnownLayout)]
201201
#[repr(C)]
202202
struct Header {
203203
magic: [u8; 6],
@@ -210,7 +210,7 @@ struct Header {
210210
_padding_2: [u8; 20],
211211
}
212212

213-
#[derive(FromZeroes, FromBytes, AsBytes)]
213+
#[derive(FromBytes, IntoBytes, Immutable, KnownLayout)]
214214
#[repr(C)]
215215
struct Timestamp {
216216
year: u8,
@@ -297,7 +297,7 @@ impl PayloadBuffer {
297297
}
298298

299299
fn header_mut(&mut self) -> &mut Header {
300-
Header::mut_from_prefix(&mut self.data).unwrap()
300+
Header::mut_from_prefix(&mut self.data).unwrap().0
301301
}
302302

303303
/// Return the current number of messages
@@ -359,7 +359,7 @@ impl PayloadBuffer {
359359

360360
let start = self.data.len();
361361
self.data.resize(start + count * 11, 0);
362-
MessageBuffer(FromBytes::mut_slice_from(&mut self.data[start..]).unwrap())
362+
MessageBuffer(FromBytes::mut_from_bytes(&mut self.data[start..]).unwrap())
363363
}
364364

365365
/// Get the current payload as bytes (without padding)

0 commit comments

Comments
 (0)