From c1b0a6f917302a7d3b0ae880d31c6a1a950c2a69 Mon Sep 17 00:00:00 2001 From: Vincent Herlemont Date: Sat, 2 Sep 2023 14:02:25 +0200 Subject: [PATCH] docs: fix example of setup serialization format --- libraries/native_model/README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/native_model/README.md b/libraries/native_model/README.md index 4fe34a3e..98282377 100644 --- a/libraries/native_model/README.md +++ b/libraries/native_model/README.md @@ -80,14 +80,17 @@ First, you need to set up your serialization format. You can use any serializati Just define the following functions, so they must be imported in the scope where you use the native model. ```rust,ignore -fn native_model_encode_body(obj: &T) -> Result, dyn Error> { +fn native_model_encode_body(obj: &T) -> Result, E> { ... } -fn native_model_decode_body(data: Vec) -> Result { +fn native_model_decode_body(data: Vec) -> Result { ... } ``` + +With `T` and `E` the type depending on the serialization format you use. Just `E` need to implement the `std::error::Error` trait. + Examples: - [bincode with encode/decode](./tests/example/encode_decode/bincode.rs) - [bincode with serde](./tests/example/encode_decode/bincode_serde.rs)