pub struct CustomTool {
pub name: String,
pub description: String,
pub base_url: String,
pub method: HttpMethod,
pub auth: AuthConfig,
pub headers: Vec<(String, String)>,
pub timeout: Duration,
pub content_type: Option<String>,
}Expand description
Configuration for a custom tool (external API call).
Fields§
§name: StringUnique name for this tool.
description: StringDescription of what this tool does.
base_url: StringBase URL for the API.
method: HttpMethodDefault HTTP method.
auth: AuthConfigAuthentication configuration.
headers: Vec<(String, String)>Additional headers.
timeout: DurationRequest timeout.
content_type: Option<String>Content type for requests.
Implementations§
Source§impl CustomTool
impl CustomTool
Sourcepub fn new(name: impl Into<String>, base_url: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, base_url: impl Into<String>) -> Self
Create a new custom tool with GET method.
Sourcepub fn with_description(self, desc: impl Into<String>) -> Self
pub fn with_description(self, desc: impl Into<String>) -> Self
Set description.
Sourcepub fn with_method(self, method: HttpMethod) -> Self
pub fn with_method(self, method: HttpMethod) -> Self
Set HTTP method.
Sourcepub fn with_bearer_auth(self, token: impl Into<String>) -> Self
pub fn with_bearer_auth(self, token: impl Into<String>) -> Self
Set bearer token authentication.
Sourcepub fn with_api_key(
self,
header: impl Into<String>,
key: impl Into<String>,
) -> Self
pub fn with_api_key( self, header: impl Into<String>, key: impl Into<String>, ) -> Self
Set API key authentication.
Sourcepub fn with_basic_auth(
self,
username: impl Into<String>,
password: impl Into<String>,
) -> Self
pub fn with_basic_auth( self, username: impl Into<String>, password: impl Into<String>, ) -> Self
Set basic authentication.
Sourcepub fn with_custom_auth(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_custom_auth( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Set custom header authentication.
Sourcepub fn with_header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Add a custom header.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set request timeout.
Sourcepub fn with_content_type(self, content_type: impl Into<String>) -> Self
pub fn with_content_type(self, content_type: impl Into<String>) -> Self
Set content type.
Trait Implementations§
Source§impl Clone for CustomTool
impl Clone for CustomTool
Source§fn clone(&self) -> CustomTool
fn clone(&self) -> CustomTool
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 CustomTool
impl RefUnwindSafe for CustomTool
impl Send for CustomTool
impl Sync for CustomTool
impl Unpin for CustomTool
impl UnwindSafe for CustomTool
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