pub struct AgentRequestBuilder { /* private fields */ }Expand description
Builder for AgentRequest with type-safe setters.
§Examples
use agentguard_core::{AgentRequestBuilder, Principal, AgentAction, Resource, AgentContext};
let req = AgentRequestBuilder::new(Principal::user("alice"))
.action(AgentAction::tool("send_email"))
.resource(Resource::new("Mailbox", "alice@acme"))
.context(AgentContext::new())
.build();Implementations§
Source§impl AgentRequestBuilder
impl AgentRequestBuilder
Sourcepub fn new(principal: impl Into<Principal>) -> Self
pub fn new(principal: impl Into<Principal>) -> Self
Start building a request for the given principal.
Sourcepub fn action(self, a: impl Into<AgentAction>) -> Self
pub fn action(self, a: impl Into<AgentAction>) -> Self
Set the action (tool call).
Sourcepub fn context(self, c: impl Into<AgentContext>) -> Self
pub fn context(self, c: impl Into<AgentContext>) -> Self
Set the context.
Sourcepub fn request_id(self, id: impl Into<String>) -> Self
pub fn request_id(self, id: impl Into<String>) -> Self
Override the auto-generated request id.
Sourcepub fn trace(self, trace: TraceContext) -> Self
pub fn trace(self, trace: TraceContext) -> Self
Attach a W3C Trace Context.
Sourcepub fn traceparent(self, tp: &str) -> Result<Self>
pub fn traceparent(self, tp: &str) -> Result<Self>
Attach a trace by parsing a traceparent string.
§Errors
Returns Error::Other (or a parse error) if the traceparent string
is malformed.
Sourcepub fn tenant_id(self, tid: impl Into<String>) -> Self
pub fn tenant_id(self, tid: impl Into<String>) -> Self
Set the tenant ID. Whitespace is trimmed; empty/whitespace-only
values become None. No other format constraint.
Sourcepub fn build(self) -> Result<AgentRequest>
pub fn build(self) -> Result<AgentRequest>
Finalize the request. Returns an error if action or resource is missing.
Trait Implementations§
Source§impl Clone for AgentRequestBuilder
impl Clone for AgentRequestBuilder
Source§fn clone(&self) -> AgentRequestBuilder
fn clone(&self) -> AgentRequestBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AgentRequestBuilder
impl RefUnwindSafe for AgentRequestBuilder
impl Send for AgentRequestBuilder
impl Sync for AgentRequestBuilder
impl Unpin for AgentRequestBuilder
impl UnwindSafe for AgentRequestBuilder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more