pulsatrix 1.1.0
Loading...
Searching...
No Matches
secret.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include <cstddef>
8#include <optional>
9#include <string>
10
11namespace pulsatrix::orch {
12
20class Secret {
21public:
23 Secret() = default;
24 explicit Secret(std::string value);
25
30 [[nodiscard]] static std::optional<Secret> FromEnv(const char* name);
31
32 Secret(const Secret& other);
33 Secret(Secret&& other) noexcept;
34 Secret& operator=(const Secret& other);
35 Secret& operator=(Secret&& other) noexcept;
37
39 [[nodiscard]] const std::string& reveal() const { return value_; }
40
41 [[nodiscard]] bool empty() const { return value_.empty(); }
42 [[nodiscard]] std::size_t size() const { return value_.size(); }
43
45 [[nodiscard]] std::string redacted() const;
46
47private:
48 void wipe() noexcept;
49
50 std::string value_;
51};
52
53} // namespace pulsatrix::orch
Holds a credential, such as an LLM provider's API key.
Definition secret.hpp:20
bool empty() const
Definition secret.hpp:41
Secret(const Secret &other)
Secret & operator=(Secret &&other) noexcept
Secret(std::string value)
std::string redacted() const
A description safe to print, for example <secret, 108 characters>.
static std::optional< Secret > FromEnv(const char *name)
Reads the environment variable name.
Secret & operator=(const Secret &other)
const std::string & reveal() const
The value, to put in a request header. Never log it.
Definition secret.hpp:39
Secret()=default
An empty secret.
std::size_t size() const
Definition secret.hpp:42
Secret(Secret &&other) noexcept
Definition http.hpp:20