Skip to content

Commit

Permalink
docs: Fix some typos and clarify the pickling docs
Browse files Browse the repository at this point in the history
Co-authored-by: Denis Kasak <[email protected]>
  • Loading branch information
poljar and dkasak committed Mar 1, 2022
1 parent 6390ad7 commit dc5b44f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ only *unpickling* is supported.

### Modern pickles

The modern pickling mechanism used by this crate. The serialization format is
based on Serde.
The crate also implements a modern pickling mechanism using
[Serde](https://serde.rs/). The exact serialization format is not mandated or
specified by this crate, but you can serialize to and deserialize from any
format supported by Serde.

The following structs support pickling:

Expand Down Expand Up @@ -160,12 +162,15 @@ You can unpickle a pickle-able struct directly from its serialized form:
```rust
# use anyhow::Result;
# use vodozemac::olm::{Account, AccountPickle};
# use zeroize::Zeroize;
#
# fn main() -> Result<()> {
# let some_account = Account::new();
let json_str = serde_json::to_string(&some_account.pickle())?;
// This will produce an account which is identitcal to `some_account`.
let mut json_str = serde_json::to_string(&some_account.pickle())?;
// This will produce an account which is identical to `some_account`.
let account: Account = serde_json::from_str::<AccountPickle>(&json_str)?.into();

json_str.zeroize();
#
# Ok(())
# }
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub enum PickleError {
Base64(#[from] base64::DecodeError),
#[error("The pickle couldn't be decrypted: {0}")]
Decryption(#[from] crate::cipher::DecryptionError),
#[error("The pickle coudn't be deserialized: {0}")]
#[error("The pickle couldn't be deserialized: {0}")]
Serialization(#[from] serde_json::Error),
}

Expand Down

0 comments on commit dc5b44f

Please sign in to comment.