systemprompt_identifiers/provider_request.rs
1//! Opaque request identifier echoed by upstream model providers.
2//!
3//! Captured for observability when a provider returns a trace token in
4//! its response (e.g. via `x-context-id` or analogous headers). The shape
5//! is provider-defined, so this id is only validated for non-empty and a
6//! sane upper length bound.
7//!
8//! Copyright (c) systemprompt.io — Business Source License 1.1.
9//! See <https://systemprompt.io> for licensing details.
10
11use crate::error::IdValidationError;
12
13const MAX_LEN: usize = 256;
14
15fn validate(value: &str) -> Result<(), IdValidationError> {
16 if value.is_empty() {
17 return Err(IdValidationError::empty("ProviderRequestId"));
18 }
19 if value.len() > MAX_LEN {
20 return Err(IdValidationError::invalid(
21 "ProviderRequestId",
22 "exceeds maximum length",
23 ));
24 }
25 Ok(())
26}
27
28crate::define_id!(ProviderRequestId, validated, schema, validate);