use super::{Command, Response};
use {Adapter, CommandType, ObjectId, ObjectType, Session, SessionError, WrapMessage, WrapNonce};
pub fn import_wrapped<A, M>(
session: &mut Session<A>,
wrap_key_id: ObjectId,
wrap_message: M,
) -> Result<ImportWrappedResponse, SessionError>
where
A: Adapter,
M: Into<WrapMessage>,
{
let WrapMessage { nonce, ciphertext } = wrap_message.into();
session.send_command(ImportWrappedCommand {
wrap_key_id,
nonce,
ciphertext,
})
}
#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct ImportWrappedCommand {
pub wrap_key_id: ObjectId,
pub nonce: WrapNonce,
pub ciphertext: Vec<u8>,
}
impl Command for ImportWrappedCommand {
type ResponseType = ImportWrappedResponse;
}
#[derive(Serialize, Deserialize, Debug)]
pub struct ImportWrappedResponse {
pub object_type: ObjectType,
pub object_id: ObjectId,
}
impl Response for ImportWrappedResponse {
const COMMAND_TYPE: CommandType = CommandType::ImportWrapped;
}