Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
djkoloski committed Mar 31, 2023
1 parent d6b1310 commit 1909e6a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 22 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@

```rust
use rkyv::{Archive, Deserialize, Serialize};
// bytecheck can be used to validate your data if you want
use bytecheck::CheckBytes;

#[derive(Archive, Deserialize, Serialize, Debug, PartialEq)]
// This will generate a PartialEq impl between our unarchived and archived types
#[archive(compare(PartialEq))]
// To use the safe API, you have to derive CheckBytes for the archived type
#[archive_attr(derive(CheckBytes, Debug))]
#[archive(
// This will generate a PartialEq impl between our unarchived and archived
// types:
compare(PartialEq),
// bytecheck can be used to validate your data if you want. To use the safe
// API, you have to derive CheckBytes for the archived type:
check_bytes,
)]
// Derives can be passed through to the generated type:
#[archive_attr(derive(Debug))]
struct Test {
int: u8,
string: String,
Expand Down
16 changes: 10 additions & 6 deletions rkyv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@

```rust
use rkyv::{Archive, Deserialize, Serialize};
// bytecheck can be used to validate your data if you want
use bytecheck::CheckBytes;

#[derive(Archive, Deserialize, Serialize, Debug, PartialEq)]
// This will generate a PartialEq impl between our unarchived and archived types
#[archive(compare(PartialEq))]
// To use the safe API, you have to derive CheckBytes for the archived type
#[archive_attr(derive(CheckBytes, Debug))]
#[archive(
// This will generate a PartialEq impl between our unarchived and archived
// types:
compare(PartialEq),
// bytecheck can be used to validate your data if you want. To use the safe
// API, you have to derive CheckBytes for the archived type:
check_bytes,
)]
// Derives can be passed through to the generated type:
#[archive_attr(derive(Debug))]
struct Test {
int: u8,
string: String,
Expand Down
16 changes: 10 additions & 6 deletions rkyv/crates-io.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@

```rust
use rkyv::{Archive, Deserialize, Serialize};
// bytecheck can be used to validate your data if you want
use bytecheck::CheckBytes;

#[derive(Archive, Deserialize, Serialize, Debug, PartialEq)]
// This will generate a PartialEq impl between our unarchived and archived types
#[archive(compare(PartialEq))]
// To use the safe API, you have to derive CheckBytes for the archived type
#[archive_attr(derive(CheckBytes, Debug))]
#[archive(
// This will generate a PartialEq impl between our unarchived and archived
// types:
compare(PartialEq),
// bytecheck can be used to validate your data if you want. To use the safe
// API, you have to derive CheckBytes for the archived type:
check_bytes,
)]
// Derives can be passed through to the generated type:
#[archive_attr(derive(Debug))]
struct Test {
int: u8,
string: String,
Expand Down
14 changes: 10 additions & 4 deletions rkyv_test/src/test_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,19 @@ mod tests {
#[allow(unused_variables)]
#[cfg_attr(feature = "wasm", wasm_bindgen_test)]
fn archive_example() {
// CheckBytes from bytecheck can be used to validate your data, if you want
use rkyv::{Archive, Deserialize, Serialize};

#[derive(Archive, Deserialize, Serialize, Debug, PartialEq)]
// This will generate a PartialEq impl between our unarchived and archived types
// To use the safe API, you have to derive CheckBytes for the archived type
#[archive(check_bytes, compare(PartialEq))]
#[archive(
// This will generate a PartialEq impl between our unarchived
// and archived types:
compare(PartialEq),
// bytecheck can be used to validate your data if you want. To
// use the safe API, you have to derive CheckBytes for the
// archived type:
check_bytes,
)]
// Derives can be passed through to the generated type:
#[archive_attr(derive(Debug))]
struct Test {
int: u8,
Expand Down

0 comments on commit 1909e6a

Please sign in to comment.