use super::{Command, Response};
use {Adapter, CommandType, ObjectId, Session, SessionError, WrapMessage};
pub fn wrap_data<A: Adapter>(
session: &mut Session<A>,
wrap_key_id: ObjectId,
plaintext: Vec<u8>,
) -> Result<WrapMessage, SessionError> {
session
.send_command(WrapDataCommand {
wrap_key_id,
plaintext,
}).map(|response| response.0)
}
#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct WrapDataCommand {
pub wrap_key_id: ObjectId,
pub plaintext: Vec<u8>,
}
impl Command for WrapDataCommand {
type ResponseType = WrapDataResponse;
}
#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct WrapDataResponse(pub(crate) WrapMessage);
impl Response for WrapDataResponse {
const COMMAND_TYPE: CommandType = CommandType::WrapData;
}