pub struct ModelFailure { /* private fields */ }Expand description
Provider-neutral terminal model failure.
Implementations§
Source§impl ModelFailure
impl ModelFailure
Sourcepub fn internal_adapter_failure() -> Self
pub fn internal_adapter_failure() -> Self
Creates a fixed internal adapter failure.
Sourcepub fn new(
code: ModelFailureCode,
message: impl Into<String>,
retry: RetryClass,
) -> Result<Self, ModelStreamValueError>
pub fn new( code: ModelFailureCode, message: impl Into<String>, retry: RetryClass, ) -> Result<Self, ModelStreamValueError>
Creates a bounded technical failure without an internal source chain.
§Errors
Returns an error when message is empty, exceeds 4 KiB, or contains a
null character.
Sourcepub fn safe(
code: ModelFailureCode,
message: impl Into<String>,
retry: RetryClass,
) -> Result<Self, ModelStreamValueError>
pub fn safe( code: ModelFailureCode, message: impl Into<String>, retry: RetryClass, ) -> Result<Self, ModelStreamValueError>
Creates a provider failure whose message was normalized for display.
The caller must have removed provider payload fields, bounded the text, and stripped terminal control characters before using this constructor.
§Errors
Returns an error when the normalized message violates the model failure bounds.
Sourcepub fn with_metadata(self, metadata: ProtocolMetadata) -> Self
pub fn with_metadata(self, metadata: ProtocolMetadata) -> Self
Adds bounded namespaced safe metadata.
Sourcepub fn with_retry_after(self, retry_after: Duration) -> Self
pub fn with_retry_after(self, retry_after: Duration) -> Self
Adds a provider-requested delay before this failure is retried.
Sourcepub const fn code(&self) -> ModelFailureCode
pub const fn code(&self) -> ModelFailureCode
Returns the stable failure code.
Sourcepub const fn retry(&self) -> RetryClass
pub const fn retry(&self) -> RetryClass
Returns the retry classification.
Sourcepub const fn retry_after(&self) -> Option<Duration>
pub const fn retry_after(&self) -> Option<Duration>
Returns the provider-requested retry delay when one was supplied.
Sourcepub const fn metadata(&self) -> &ProtocolMetadata
pub const fn metadata(&self) -> &ProtocolMetadata
Returns safe namespaced metadata.
Sourcepub const fn is_safe_diagnostic(&self) -> bool
pub const fn is_safe_diagnostic(&self) -> bool
Returns whether the message is safe to expose as provider diagnostics.
Trait Implementations§
Source§impl Clone for ModelFailure
impl Clone for ModelFailure
Source§fn clone(&self) -> ModelFailure
fn clone(&self) -> ModelFailure
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more