1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use super::put_object::PutObjectParams;
use super::{Command, Response};
use {
Adapter, Capability, CommandType, Domain, ObjectId, ObjectLabel, OpaqueAlg, Session,
SessionError,
};
pub fn put_opaque<A: Adapter, T: Into<Vec<u8>>>(
session: &mut Session<A>,
object_id: ObjectId,
label: ObjectLabel,
domains: Domain,
capabilities: Capability,
algorithm: OpaqueAlg,
bytes: T,
) -> Result<ObjectId, SessionError> {
session
.send_command(PutOpaqueCommand {
params: PutObjectParams {
id: object_id,
label,
domains,
capabilities,
algorithm: algorithm.into(),
},
data: bytes.into(),
}).map(|response| response.object_id)
}
#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct PutOpaqueCommand {
pub params: PutObjectParams,
pub data: Vec<u8>,
}
impl Command for PutOpaqueCommand {
type ResponseType = PutOpaqueResponse;
}
#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct PutOpaqueResponse {
pub object_id: ObjectId,
}
impl Response for PutOpaqueResponse {
const COMMAND_TYPE: CommandType = CommandType::PutOpaqueObject;
}