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
//! Delete an object of the given ID and type
//!
//! <https://developers.yubico.com/YubiHSM2/Commands/Blink.html>

use super::{Command, Response};
use {Adapter, CommandType, ObjectId, ObjectType, Session, SessionError};

/// Delete an object of the given ID and type
pub fn delete_object<A: Adapter>(
    session: &mut Session<A>,
    object_id: ObjectId,
    object_type: ObjectType,
) -> Result<(), SessionError> {
    session.send_command(DeleteObjectCommand {
        object_id,
        object_type,
    })?;
    Ok(())
}

/// Request parameters for `command::delete_object`
#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct DeleteObjectCommand {
    /// Object ID to delete
    pub object_id: ObjectId,

    /// Type of object to delete
    pub object_type: ObjectType,
}

impl Command for DeleteObjectCommand {
    type ResponseType = DeleteObjectResponse;
}

/// Response from `command::delete_object`
#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct DeleteObjectResponse {}

impl Response for DeleteObjectResponse {
    const COMMAND_TYPE: CommandType = CommandType::DeleteObject;
}