pub struct MessageView<'a> { /* private fields */ }Expand description
Read-only, zero-copy view over a single content part.
Provides a uniform interface for policy evaluation regardless of content type. Properties are computed on-demand by borrowing the underlying content part and extensions.
Produced by Message::iter_views() or the standalone iter_views().
Implementations§
Source§impl<'a> MessageView<'a>
impl<'a> MessageView<'a>
Sourcepub fn new(
part: &'a ContentPart,
role: Role,
hook: Option<&'a str>,
extensions: Option<&'a Extensions>,
) -> Self
pub fn new( part: &'a ContentPart, role: Role, hook: Option<&'a str>, extensions: Option<&'a Extensions>, ) -> Self
Create a new view over a content part.
Sourcepub fn raw(&self) -> &'a ContentPart
pub fn raw(&self) -> &'a ContentPart
The underlying content part.
Sourcepub fn action(&self) -> ViewAction
pub fn action(&self) -> ViewAction
The action this content represents.
Sourcepub fn is_pre(&self) -> bool
pub fn is_pre(&self) -> bool
Whether this is a pre-execution hook (tool_pre_invoke, prompt_pre_fetch, etc.).
Sourcepub fn args(&self) -> Option<&HashMap<String, Value>>
pub fn args(&self) -> Option<&HashMap<String, Value>>
Arguments (for tool calls and prompt requests).
pub fn is_tool(&self) -> bool
pub fn is_resource(&self) -> bool
pub fn is_prompt(&self) -> bool
pub fn is_media(&self) -> bool
pub fn is_text(&self) -> bool
Sourcepub fn extensions(&self) -> Option<&'a Extensions>
pub fn extensions(&self) -> Option<&'a Extensions>
Get the extensions, if provided.
Sourcepub fn get_header(&self, name: &str) -> Option<&str>
pub fn get_header(&self, name: &str) -> Option<&str>
Get an HTTP header value.
Sourcepub fn to_dict(&self, include_content: bool, include_context: bool) -> Value
pub fn to_dict(&self, include_content: bool, include_context: bool) -> Value
Serialize the view to a JSON-compatible map.
Includes the view’s properties, arguments, and optionally text content and extension context. Sensitive headers (Authorization, Cookie, X-API-Key) are stripped.
Sourcepub fn to_opa_input(&self, include_content: bool) -> Value
pub fn to_opa_input(&self, include_content: bool) -> Value
Serialize to OPA-compatible input format.
Wraps the view in the standard OPA input envelope:
{"input": {...view data...}}.