use core::fmt;
use zeroize::Zeroize;
use super::DescribeDelegationTokenPrincipal;
#[derive(Eq, PartialEq)]
pub struct DescribeDelegationTokenHmac {
bytes: Vec<u8>,
}
impl DescribeDelegationTokenHmac {
pub(super) const fn new(bytes: Vec<u8>) -> Self {
Self { bytes }
}
pub fn as_bytes(&self) -> &[u8] {
&self.bytes
}
pub fn into_bytes(mut self) -> Vec<u8> {
core::mem::take(&mut self.bytes)
}
}
impl Drop for DescribeDelegationTokenHmac {
fn drop(&mut self) {
self.bytes.zeroize();
}
}
impl fmt::Debug for DescribeDelegationTokenHmac {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("[REDACTED]")
}
}
#[derive(Debug, Eq, PartialEq)]
pub struct DescribedDelegationToken {
pub(super) owner: DescribeDelegationTokenPrincipal,
pub(super) requester: Option<DescribeDelegationTokenPrincipal>,
pub(super) renewers: Vec<DescribeDelegationTokenPrincipal>,
pub(super) issue_timestamp_ms: i64,
pub(super) expiry_timestamp_ms: i64,
pub(super) max_timestamp_ms: i64,
pub(super) token_id: String,
pub(super) hmac: DescribeDelegationTokenHmac,
}
impl DescribedDelegationToken {
pub const fn owner(&self) -> &DescribeDelegationTokenPrincipal {
&self.owner
}
pub const fn requester(&self) -> Option<&DescribeDelegationTokenPrincipal> {
self.requester.as_ref()
}
pub fn renewers(&self) -> &[DescribeDelegationTokenPrincipal] {
&self.renewers
}
pub const fn issue_timestamp_ms(&self) -> i64 {
self.issue_timestamp_ms
}
pub const fn expiry_timestamp_ms(&self) -> i64 {
self.expiry_timestamp_ms
}
pub const fn max_timestamp_ms(&self) -> i64 {
self.max_timestamp_ms
}
pub fn token_id(&self) -> &str {
&self.token_id
}
pub const fn hmac(&self) -> &DescribeDelegationTokenHmac {
&self.hmac
}
#[allow(clippy::type_complexity)]
pub fn into_parts(
self,
) -> (
DescribeDelegationTokenPrincipal,
Option<DescribeDelegationTokenPrincipal>,
Vec<DescribeDelegationTokenPrincipal>,
i64,
i64,
i64,
String,
DescribeDelegationTokenHmac,
) {
(
self.owner,
self.requester,
self.renewers,
self.issue_timestamp_ms,
self.expiry_timestamp_ms,
self.max_timestamp_ms,
self.token_id,
self.hmac,
)
}
}
#[derive(Debug, Eq, PartialEq)]
pub struct DescribeDelegationTokensResult {
pub(super) throttle_time_ms: u32,
pub(super) tokens: Vec<DescribedDelegationToken>,
}
impl DescribeDelegationTokensResult {
pub const fn throttle_time_ms(&self) -> u32 {
self.throttle_time_ms
}
pub fn tokens(&self) -> &[DescribedDelegationToken] {
&self.tokens
}
pub fn into_parts(self) -> (u32, Vec<DescribedDelegationToken>) {
(self.throttle_time_ms, self.tokens)
}
}