pub struct MiddlewareContext {
pub request_id: Option<String>,
pub trace_id: Option<String>,
pub parent_span_id: Option<String>,
pub operation: Option<String>,
}Expand description
Structured fields carried across the middleware chain.
Round-trips through serde_json so the bag stays JSON-compatible with the
rest of provider_options.
Fields§
§request_id: Option<String>Unique id for this end-to-end request.
trace_id: Option<String>Trace id for distributed tracing (W3C trace-context style).
parent_span_id: Option<String>Parent span id within the trace.
operation: Option<String>Logical operation name (e.g. "chat.completion", "embed.query").
Implementations§
Source§impl MiddlewareContext
impl MiddlewareContext
Sourcepub fn with_request_id(id: impl Into<String>) -> Self
pub fn with_request_id(id: impl Into<String>) -> Self
Build with a fresh request id.
Sourcepub fn read(options: &CallOptions) -> Option<Self>
pub fn read(options: &CallOptions) -> Option<Self>
Read the context (if any) from a CallOptions.
Returns None when no llmsdk bucket exists or when its contents
don’t deserialize as MiddlewareContext.
Sourcepub fn read_from(options: &ProviderOptions) -> Option<Self>
pub fn read_from(options: &ProviderOptions) -> Option<Self>
Read from a raw ProviderOptions map.
Sourcepub fn write(&self, options: &mut CallOptions)
pub fn write(&self, options: &mut CallOptions)
Write self into a CallOptions, merging onto any existing
llmsdk bucket (caller fields win).
Trait Implementations§
Source§impl Clone for MiddlewareContext
impl Clone for MiddlewareContext
Source§fn clone(&self) -> MiddlewareContext
fn clone(&self) -> MiddlewareContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MiddlewareContext
impl Debug for MiddlewareContext
Source§impl Default for MiddlewareContext
impl Default for MiddlewareContext
Source§fn default() -> MiddlewareContext
fn default() -> MiddlewareContext
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for MiddlewareContext
impl<'de> Deserialize<'de> for MiddlewareContext
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for MiddlewareContext
impl PartialEq for MiddlewareContext
Source§fn eq(&self, other: &MiddlewareContext) -> bool
fn eq(&self, other: &MiddlewareContext) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for MiddlewareContext
impl Serialize for MiddlewareContext
impl Eq for MiddlewareContext
impl StructuralPartialEq for MiddlewareContext
Auto Trait Implementations§
impl Freeze for MiddlewareContext
impl RefUnwindSafe for MiddlewareContext
impl Send for MiddlewareContext
impl Sync for MiddlewareContext
impl Unpin for MiddlewareContext
impl UnsafeUnpin for MiddlewareContext
impl UnwindSafe for MiddlewareContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more