#![deny(
missing_docs,
missing_debug_implementations,
missing_copy_implementations,
elided_lifetimes_in_paths,
rust_2018_idioms,
clippy::cargo_common_metadata,
clippy::fallible_impl_from,
clippy::missing_const_for_fn,
intra_doc_link_resolution_failure
)]
#[allow(unused_extern_crates)]
extern crate libsignal_protocol_sys as sys;
#[cfg(feature = "crypto-openssl")]
#[macro_use]
extern crate rental;
use std::io::Write;
use failure::Error;
pub use crate::{
address::Address,
buffer::Buffer,
context::*,
errors::{FromInternalErrorCode, InternalError, IntoInternalErrorCode},
hkdf::HMACBasedKeyDerivationFunction,
pre_key_bundle::{PreKeyBundle, PreKeyBundleBuilder},
session_builder::SessionBuilder,
session_cipher::SessionCipher,
session_record::SessionRecord,
session_state::SessionState,
store_context::StoreContext,
};
#[allow(unused_imports)]
use crate::messages::PreKeySignalMessage;
#[allow(unused_imports)]
use crate::stores::{
IdentityKeyStore, PreKeyStore, SessionStore, SignedPreKeyStore,
};
#[macro_use]
mod macros;
mod address;
mod buffer;
mod context;
pub mod crypto;
mod errors;
mod hkdf;
pub mod keys;
pub mod messages;
mod pre_key_bundle;
pub(crate) mod raw_ptr;
mod session_builder;
mod session_cipher;
mod session_record;
mod session_state;
mod store_context;
pub mod stores;
pub trait Serializable {
fn serialize(&self) -> Result<Buffer, Error>;
fn deserialize(data: &[u8]) -> Result<Self, Error>
where
Self: Sized;
fn serialize_to<W: Write>(&self, mut writer: W) -> Result<(), Error> {
let buffer = self.serialize()?;
writer.write_all(buffer.as_slice())?;
Ok(())
}
}