mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-07-27 02:04:39 +10:00
chore: Remove trailing whitespaces
This commit is contained in:
committed by
Vincent Herlemont
parent
e75e945383
commit
28d41a41e9
@@ -11,7 +11,7 @@ See [concepts](#concepts) for more details.
|
|||||||
|
|
||||||
## Goals
|
## Goals
|
||||||
|
|
||||||
- **Interoperability**: Allows different applications to work together, even if they are using different
|
- **Interoperability**: Allows different applications to work together, even if they are using different
|
||||||
versions of the data model.
|
versions of the data model.
|
||||||
- **Data Consistency**: Ensure that we process the data expected model.
|
- **Data Consistency**: Ensure that we process the data expected model.
|
||||||
- **Flexibility**: You can use any serialization format you want. More details [here](#setup-your-serialization-format).
|
- **Flexibility**: You can use any serialization format you want. More details [here](#setup-your-serialization-format).
|
||||||
@@ -39,10 +39,10 @@ let bytes = native_model::encode(&dot).unwrap();
|
|||||||
// Application 2
|
// Application 2
|
||||||
// We are able to decode the bytes directly into a new type DotV2 (upgrade).
|
// We are able to decode the bytes directly into a new type DotV2 (upgrade).
|
||||||
let (mut dot, source_version) = native_model::decode::<DotV2>(bytes).unwrap();
|
let (mut dot, source_version) = native_model::decode::<DotV2>(bytes).unwrap();
|
||||||
assert_eq!(dot, DotV2 {
|
assert_eq!(dot, DotV2 {
|
||||||
name: "".to_string(),
|
name: "".to_string(),
|
||||||
x: 1,
|
x: 1,
|
||||||
y: 2
|
y: 2
|
||||||
});
|
});
|
||||||
dot.name = "Dot".to_string();
|
dot.name = "Dot".to_string();
|
||||||
dot.x = 5;
|
dot.x = 5;
|
||||||
@@ -78,7 +78,7 @@ changes, the default serialization format is the oldest one.
|
|||||||
|
|
||||||
Define a struct with the name you want. This struct must implement [`native_model::Encode`](https://docs.rs/native_model/latest/native_model/trait.Encode.html) and [`native_model::Decode`](https://docs.rs/native_model/latest/native_model/trait.Decode.html) traits.
|
Define a struct with the name you want. This struct must implement [`native_model::Encode`](https://docs.rs/native_model/latest/native_model/trait.Encode.html) and [`native_model::Decode`](https://docs.rs/native_model/latest/native_model/trait.Decode.html) traits.
|
||||||
|
|
||||||
Full examples:
|
Full examples:
|
||||||
- [bincode with encode/decode](./tests_crate/tests/example/custom_codec/bincode.rs)
|
- [bincode with encode/decode](./tests_crate/tests/example/custom_codec/bincode.rs)
|
||||||
- [bincode with serde](./tests_crate/tests/example/custom_codec/bincode_serde.rs)
|
- [bincode with serde](./tests_crate/tests/example/custom_codec/bincode_serde.rs)
|
||||||
|
|
||||||
@@ -189,9 +189,9 @@ Early development. Not ready for production.
|
|||||||
|
|
||||||
In order to understand how the native model works, you need to understand the following concepts.
|
In order to understand how the native model works, you need to understand the following concepts.
|
||||||
|
|
||||||
- **Identity**(`id`): The identity is the unique identifier of the model. It is used to identify the model and
|
- **Identity**(`id`): The identity is the unique identifier of the model. It is used to identify the model and
|
||||||
prevent to decode a model into the wrong Rust type.
|
prevent to decode a model into the wrong Rust type.
|
||||||
- **Version**(`version`) The version is the version of the model. It is used to check the compatibility between two
|
- **Version**(`version`) The version is the version of the model. It is used to check the compatibility between two
|
||||||
models.
|
models.
|
||||||
- **Encode**: The encode is the process of converting a model into a byte array.
|
- **Encode**: The encode is the process of converting a model into a byte array.
|
||||||
- **Decode**: The decode is the process of converting a byte array into a model.
|
- **Decode**: The decode is the process of converting a byte array into a model.
|
||||||
@@ -212,7 +212,7 @@ Full example [here](tests/example/example_define_model.rs).
|
|||||||
|
|
||||||
Native model has
|
Native model has
|
||||||
been designed to have a minimal and constant overhead. That means that the overhead is the same
|
been designed to have a minimal and constant overhead. That means that the overhead is the same
|
||||||
whatever the size of the data. Under the hood we use the [zerocopy](https://docs.rs/zerocopy/latest/zerocopy/) crate
|
whatever the size of the data. Under the hood we use the [zerocopy](https://docs.rs/zerocopy/latest/zerocopy/) crate
|
||||||
to avoid unnecessary copies.
|
to avoid unnecessary copies.
|
||||||
|
|
||||||
👉 To know the total time of the encode/decode, you need to add the time of your serialization format.
|
👉 To know the total time of the encode/decode, you need to add the time of your serialization format.
|
||||||
|
|||||||
Reference in New Issue
Block a user