Struct SdkConfig

Source
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

Source

pub fn new(api_key: String) -> Self

Creates a new configuration with the specified API key

§Arguments
  • api_key - The Serper API key
§Returns

A new SdkConfig with default values

Source

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

Source

pub fn validate(&self) -> Result<()>

Validates the configuration

§Returns

Result indicating whether the configuration is valid

Source

pub fn with_base_url(self, base_url: String) -> Self

Sets the base URL

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Sets the timeout

Source

pub fn with_max_concurrent(self, max_concurrent: usize) -> Self

Sets the maximum concurrent requests

Source

pub fn with_header(self, key: String, value: String) -> Self

Adds a default header

Source

pub fn with_user_agent(self, user_agent: String) -> Self

Sets the user agent

Source

pub fn with_logging(self, enable: bool) -> Self

Enables or disables logging

Trait Implementations§

Source§

impl Clone for SdkConfig

Source§

fn clone(&self) -> SdkConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SdkConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,