This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory-site.git
The following commit(s) were added to refs/heads/main by this push:
new b695e3a18 🔄 synced local 'docs/guide/' with remote 'docs/guide/'
b695e3a18 is described below
commit b695e3a18a15a7e71738d5dba2f212875d990e7d
Author: chaokunyang <[email protected]>
AuthorDate: Fri Oct 24 06:52:10 2025 +0000
🔄 synced local 'docs/guide/' with remote 'docs/guide/'
---
docs/guide/rust_guide.md | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/docs/guide/rust_guide.md b/docs/guide/rust_guide.md
index d8f81fbe0..ccd82d122 100644
--- a/docs/guide/rust_guide.md
+++ b/docs/guide/rust_guide.md
@@ -58,7 +58,7 @@ fory = "0.13"
### Basic Example
```rust
-use fory::{Fory, Error};
+use fory::{Fory, Error, Reader};
use fory::ForyObject;
#[derive(ForyObject, Debug, PartialEq)]
@@ -70,7 +70,7 @@ struct User {
fn main() -> Result<(), Error> {
let mut fory = Fory::default();
- fory.register::<User>(1);
+ fory.register::<User>(1)?;
let user = User {
name: "Alice".to_string(),
@@ -79,12 +79,18 @@ fn main() -> Result<(), Error> {
};
// Serialize
- let bytes = fory.serialize(&user);
-
+ let bytes = fory.serialize(&user)?;
// Deserialize
let decoded: User = fory.deserialize(&bytes)?;
assert_eq!(user, decoded);
+ // Serialize to specified buffer
+ let mut buf: Vec<u8> = vec![];
+ fory.serialize_to(&user, &mut buf)?;
+ // Deserialize from specified buffer
+ let mut reader = Reader::new(&buf);
+ let decoded: User = fory.deserialize_from(&mut reader)?;
+ assert_eq!(user, decoded);
Ok(())
}
```
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]