use std::error::Error;
use std::fmt::Debug;
use serde::{Deserialize, Serialize};
use crate::crypto::Rng;
use crate::crypto::x25519::SecretKey;
use crate::key_bundle::{Lifetime, LongTermKeyBundle, OneTimeKeyBundle, OneTimePreKeyId, PreKeyId};
pub trait IdentityManager<Y> {
fn identity_secret(y: &Y) -> &SecretKey;
}
pub trait PreKeyManager {
type State: Debug + Serialize + for<'a> Deserialize<'a>;
type Error: Error;
fn prekey_secret<'a>(
y: &'a Self::State,
id: &'a PreKeyId,
) -> Result<&'a SecretKey, Self::Error>;
fn rotate_prekey(
y: Self::State,
lifetime: Lifetime,
rng: &Rng,
) -> Result<Self::State, Self::Error>;
fn prekey_bundle(y: &Self::State) -> Result<LongTermKeyBundle, Self::Error>;
fn generate_onetime_bundle(
y: Self::State,
rng: &Rng,
) -> Result<(Self::State, OneTimeKeyBundle), Self::Error>;
fn use_onetime_secret(
y: Self::State,
id: OneTimePreKeyId,
) -> Result<(Self::State, Option<SecretKey>), Self::Error>;
}