pub struct SafetyPolicyDescriptor {
pub id: String,
pub version: String,
pub tokenizers: Vec<String>,
pub categories: Vec<Category>,
pub category_registry: Option<String>,
pub classifier: ClassifierBlock,
pub rules_summary: Option<RulesSummary>,
pub client_hooks: Option<ClientHooksBlock>,
pub published_at: Option<String>,
pub publisher: Option<PublisherBlock>,
}Expand description
The sanitized, publishable safety-policy descriptor.
Matches spec/safety-policy.schema.json v1. Field order mirrors the
TS / Python clients so canonical JSON output is byte-identical.
Fields§
§id: String§version: String§tokenizers: Vec<String>§categories: Vec<Category>§category_registry: Option<String>§classifier: ClassifierBlock§rules_summary: Option<RulesSummary>§client_hooks: Option<ClientHooksBlock>§published_at: Option<String>§publisher: Option<PublisherBlock>Implementations§
Source§impl SafetyPolicyDescriptor
impl SafetyPolicyDescriptor
Sourcepub fn from_json(bytes: &[u8]) -> Result<Self, SafetyPolicyError>
pub fn from_json(bytes: &[u8]) -> Result<Self, SafetyPolicyError>
Parse + validate a JSON byte slice into a SafetyPolicyDescriptor.
Validates first via validate_safety_policy for clean error
messages, then deserializes via serde. Rejects shapes the
validator accepts but serde would silently coerce (e.g. extra
fields are ignored on the rust side which is the desired
forward-compat behavior).
Sourcepub fn canonical_bytes(&self) -> Result<Vec<u8>, SafetyPolicyError>
pub fn canonical_bytes(&self) -> Result<Vec<u8>, SafetyPolicyError>
Canonical JSON serialization for hashing + well-known publish.
Matches the TS / Python / supervisor format: 2-space indent +
trailing newline. Fields with None values are omitted (via
serde’s skip_serializing_if) so the canonical bytes match
across stacks.
Sourcepub fn hash(&self) -> Result<String, SafetyPolicyError>
pub fn hash(&self) -> Result<String, SafetyPolicyError>
Canonical sha256 hash of a descriptor.
Returns sha256:<64 hex chars> matching what
codecai-maps policies hash emits and what servers should
publish in READY.safety_policy_hash.
Trait Implementations§
Source§impl Clone for SafetyPolicyDescriptor
impl Clone for SafetyPolicyDescriptor
Source§fn clone(&self) -> SafetyPolicyDescriptor
fn clone(&self) -> SafetyPolicyDescriptor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SafetyPolicyDescriptor
impl Debug for SafetyPolicyDescriptor
Source§impl<'de> Deserialize<'de> for SafetyPolicyDescriptor
impl<'de> Deserialize<'de> for SafetyPolicyDescriptor
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for SafetyPolicyDescriptor
impl PartialEq for SafetyPolicyDescriptor
Source§fn eq(&self, other: &SafetyPolicyDescriptor) -> bool
fn eq(&self, other: &SafetyPolicyDescriptor) -> bool
self and other values to be equal, and is used by ==.