pulsatrix 1.1.0
Loading...
Searching...
No Matches
pulsatrix::orch::Secret Class Reference

Holds a credential, such as an LLM provider's API key. More...

#include <secret.hpp>

Public Member Functions

 Secret ()=default
 An empty secret.
 
 Secret (std::string value)
 
 Secret (const Secret &other)
 
 Secret (Secret &&other) noexcept
 
Secret & operator= (const Secret &other)
 
Secret & operator= (Secret &&other) noexcept
 
 ~Secret ()
 
const std::string & reveal () const
 The value, to put in a request header. Never log it.
 
bool empty () const
 
std::size_t size () const
 
std::string redacted () const
 A description safe to print, for example <secret, 108 characters>.
 

Static Public Member Functions

static std::optional< Secret > FromEnv (const char *name)
 Reads the environment variable name.
 

Detailed Description

Holds a credential, such as an LLM provider's API key.

Note
There is no operator<< and no conversion to std::string, so a Secret can't end up in a log line or an error message by accident: the only way to read it is reveal(), which is easy to search for. redacted() describes it without its contents. The memory holding the value is overwritten when the Secret is destroyed or assigned over.

Constructor & Destructor Documentation

◆ Secret() [1/4]

pulsatrix::orch::Secret::Secret ( )
default

An empty secret.

◆ Secret() [2/4]

pulsatrix::orch::Secret::Secret ( std::string  value)
explicit

◆ Secret() [3/4]

pulsatrix::orch::Secret::Secret ( const Secret &  other)

◆ Secret() [4/4]

pulsatrix::orch::Secret::Secret ( Secret &&  other)
noexcept

◆ ~Secret()

pulsatrix::orch::Secret::~Secret ( )

Member Function Documentation

◆ empty()

bool pulsatrix::orch::Secret::empty ( ) const
inline

◆ FromEnv()

static std::optional< Secret > pulsatrix::orch::Secret::FromEnv ( const char *  name)
static

Reads the environment variable name.

Returns
The value, or std::nullopt if the variable isn't set or is empty.

◆ operator=() [1/2]

Secret & pulsatrix::orch::Secret::operator= ( const Secret &  other)

◆ operator=() [2/2]

Secret & pulsatrix::orch::Secret::operator= ( Secret &&  other)
noexcept

◆ redacted()

std::string pulsatrix::orch::Secret::redacted ( ) const

A description safe to print, for example <secret, 108 characters>.

◆ reveal()

const std::string & pulsatrix::orch::Secret::reveal ( ) const
inline

The value, to put in a request header. Never log it.

◆ size()

std::size_t pulsatrix::orch::Secret::size ( ) const
inline

The documentation for this class was generated from the following file: