pdk-contracts-lib 1.9.1-alpha.2

PDK Contracts Library
Documentation
// Copyright (c) 2026, Salesforce, Inc.,
// All rights reserved.
// For full license text, see the LICENSE.txt file

use std::{
    any::type_name,
    fmt::{Debug, Display},
};

use zeroize::ZeroizeOnDrop;

/// Represents a client ID credential.
#[derive(Debug, Clone)]
pub struct ClientId(String);

impl ClientId {
    /// Creates a new [ClientId] from a [String].
    pub fn new(id: String) -> Self {
        Self(id)
    }

    pub fn into_string(self) -> String {
        self.0
    }

    pub fn as_str(&self) -> &str {
        &self.0
    }
}

impl Display for ClientId {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.0)
    }
}

/// Represents a client secret credential.
/// This type ensures secure memory management by zeroing memory on drop.
/// [Debug] printing is safe since the internal representation is hidden.
#[derive(Clone, ZeroizeOnDrop)]
pub struct ClientSecret(String);

impl ClientSecret {
    /// Creates a new [ClientSecret] from a [String].
    pub fn new(client_secret: String) -> Self {
        Self(client_secret)
    }

    pub(crate) fn as_str(&self) -> &str {
        self.0.as_str()
    }
}

impl Debug for ClientSecret {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_tuple(type_name::<Self>())
            .field(&"**********")
            .finish()
    }
}