🚧 🚧 🚧 🚧 🚧 Under construction - DO NOT USE 🚧 🚧 🚧 🚧 🚧
Install the Python package pbtools and use it to generate Rust source code from protobuf specification(s). Add the generated files to your projects crate. Add this crate as a dependency in your project's Cargo.toml file and you should be good to go.
🚧 🚧 🚧 🚧 🚧 Under construction - DO NOT USE 🚧 🚧 🚧 🚧 🚧
``` rust use addressbook::{AddressBook, Person}; use addressbook::person::{PhoneNumber, PhoneType};
fn main() { // Encode. let mut addressbook = AddressBook { people: vec![ Person { name: String::from("Kalle Kula"), id: 56, email: String::from("kalle.kula@foobar.com"), phones: vec![ PhoneNumber { number: String::from("+46701232345"), type: PhoneType::HOME }, PhoneNumber { number: String::from("+46999999999"), type_: PhoneType::WORK } ] } ] };
let encoded = address_book.encode();
println!("Encoded: {:?}", encoded);
// Decode.
address_book = Default::default();
match address_book.decode(encoded) {
Ok(()) => println!("Ok!"),
Err(message) => println!("Error: {}", message)
}
println!("Decoded:\n{:#?}", address_book);
} ```