Base: codex-main originale (prima del fork aKode)

This commit is contained in:
Andrea
2026-11-09 10:37:42 +01:00
commit 7874033c81
10166 changed files with 2728937 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
load("//:defs.bzl", "codex_rust_crate")
codex_rust_crate(
name = "redacted-string",
crate_name = "codex_utils_redacted_string",
)

View File

@@ -0,0 +1,16 @@
[package]
name = "codex-utils-redacted-string"
version.workspace = true
edition.workspace = true
license.workspace = true
[lints]
workspace = true
[dependencies]
schemars = { workspace = true }
serde = { workspace = true, features = ["derive"] }
[lib]
test = false
doctest = false

View File

@@ -0,0 +1,71 @@
use schemars::JsonSchema;
use serde::Deserialize;
use serde::Serialize;
use serde::Serializer;
use std::fmt;
use std::ops::Deref;
use std::ops::DerefMut;
/// A string whose `Debug` output is redacted.
#[derive(Clone, Default, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
#[serde(transparent)]
pub struct RedactedString(String);
impl RedactedString {
pub fn into_inner(self) -> String {
self.0
}
}
impl Deref for RedactedString {
type Target = String;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for RedactedString {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl From<String> for RedactedString {
fn from(value: String) -> Self {
Self(value)
}
}
impl From<&str> for RedactedString {
fn from(value: &str) -> Self {
Self(value.to_owned())
}
}
impl fmt::Debug for RedactedString {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("<redacted>")
}
}
/// An API response string whose serialized form always hides the value.
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
#[serde(transparent)]
pub struct SerdeRedactedString(RedactedString);
impl SerdeRedactedString {
pub const PLACEHOLDER: &'static str = "[redacted]";
}
impl From<RedactedString> for SerdeRedactedString {
fn from(value: RedactedString) -> Self {
Self(value)
}
}
impl Serialize for SerdeRedactedString {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(Self::PLACEHOLDER)
}
}