Skip to main content
Version: dev

Rust Setup

Fory Rust provides xlang and native Object Serialization, standard Row Format, generated models, and Fory gRPC. The public fory crate is published on crates.io, supports Rust 1.70 or later, and uses the Rust 2021 edition.

Verify the Toolchain

rustc --version
cargo --version

Object Serialization

Add the public crate:

Cargo.toml
[dependencies]
fory = "1.5.0"
use fory::{Error, Fory, ForyStruct};

#[derive(ForyStruct, Debug, PartialEq)]
struct User {
id: i64,
name: String,
}

fn main() -> Result<(), Error> {
let mut fory = Fory::builder().xlang(true).build();
fory.register::<User>(1)?;

let user = User {
id: 1,
name: "Alice".to_string(),
};
let bytes = fory.serialize(&user)?;
let decoded: User = fory.deserialize(&bytes)?;
assert_eq!(user, decoded);
Ok(())
}

Use xlang mode for cross-language data and native mode for Rust-only data. Continue with Rust Object Serialization, configuration, and type registration.

Other Capabilities