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
use serde::{Deserialize, Serialize};
use zeroize::Zeroize;

/// A Handle to a cryptographic Secret.
///
/// Individual Vault implementations should map secret handles into
/// implementation-specific `Secret` representations. (e.g. binaries, or
/// HSM references) stored inside a Vault. (e.g. using `HashMap`)
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug, Zeroize)]
#[zeroize(drop)]
pub struct Secret {
    index: usize,
}

impl Secret {
    /// Return the index of this secret.
    pub fn index(&self) -> usize {
        self.index
    }
}

impl Secret {
    /// Create a new secret at the given index.
    pub fn new(index: usize) -> Self {
        Secret { index }
    }
}