pub struct SdkConfig {
pub api_key: String,
pub base_url: String,
pub timeout: Duration,
pub max_concurrent_requests: usize,
pub default_headers: HashMap<String, String>,
pub user_agent: String,
pub enable_logging: bool,
}
Expand description
Main SDK configuration
This struct contains all configuration options for the Serper SDK, with sensible defaults and environment variable support.
Fields§
§api_key: String
API key for authentication
base_url: String
Base URL for the API
timeout: Duration
Request timeout duration
max_concurrent_requests: usize
Maximum number of concurrent requests
default_headers: HashMap<String, String>
Default headers to include with all requests
user_agent: String
User agent string
enable_logging: bool
Enable request/response logging
Implementations§
Source§impl SdkConfig
impl SdkConfig
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Creates configuration from environment variables
Expected environment variables:
SERPER_API_KEY
(required)SERPER_BASE_URL
(optional)SERPER_TIMEOUT_SECS
(optional)SERPER_MAX_CONCURRENT
(optional)SERPER_USER_AGENT
(optional)SERPER_ENABLE_LOGGING
(optional)
§Returns
Result containing the configuration or an error if required variables are missing
Sourcepub fn with_base_url(self, base_url: String) -> Self
pub fn with_base_url(self, base_url: String) -> Self
Sets the base URL
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Sets the timeout
Sourcepub fn with_max_concurrent(self, max_concurrent: usize) -> Self
pub fn with_max_concurrent(self, max_concurrent: usize) -> Self
Sets the maximum concurrent requests
Sourcepub fn with_header(self, key: String, value: String) -> Self
pub fn with_header(self, key: String, value: String) -> Self
Adds a default header
Sourcepub fn with_user_agent(self, user_agent: String) -> Self
pub fn with_user_agent(self, user_agent: String) -> Self
Sets the user agent
Sourcepub fn with_logging(self, enable: bool) -> Self
pub fn with_logging(self, enable: bool) -> Self
Enables or disables logging
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SdkConfig
impl RefUnwindSafe for SdkConfig
impl Send for SdkConfig
impl Sync for SdkConfig
impl Unpin for SdkConfig
impl UnwindSafe for SdkConfig
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