pub struct SearchService {
http_client: SerperHttpClient,
}
Expand description
Main search service for the Serper SDK
This service provides the primary interface for search operations, combining query building, HTTP client management, and response processing.
Fields§
§http_client: SerperHttpClient
Implementations§
Source§impl SearchService
impl SearchService
Sourcepub fn with_config(
api_key: String,
base_url: String,
config: TransportConfig,
) -> Result<Self>
pub fn with_config( api_key: String, base_url: String, config: TransportConfig, ) -> Result<Self>
Sourcepub async fn search(&self, query: &SearchQuery) -> Result<SearchResponse>
pub async fn search(&self, query: &SearchQuery) -> Result<SearchResponse>
Sourcepub async fn search_simple(&self, query_string: &str) -> Result<SearchResponse>
pub async fn search_simple(&self, query_string: &str) -> Result<SearchResponse>
Sourcepub async fn search_multiple(
&self,
queries: &[SearchQuery],
) -> Result<Vec<SearchResponse>>
pub async fn search_multiple( &self, queries: &[SearchQuery], ) -> Result<Vec<SearchResponse>>
Sourcepub async fn search_concurrent(
&self,
queries: &[SearchQuery],
max_concurrent: Option<usize>,
) -> Result<Vec<SearchResponse>>
pub async fn search_concurrent( &self, queries: &[SearchQuery], max_concurrent: Option<usize>, ) -> Result<Vec<SearchResponse>>
Sourcepub fn query_builder(&self) -> SearchQueryBuilder
pub fn query_builder(&self) -> SearchQueryBuilder
Sourcepub async fn search_with<F>(&self, builder_fn: F) -> Result<SearchResponse>
pub async fn search_with<F>(&self, builder_fn: F) -> Result<SearchResponse>
Searches with query builder pattern
§Arguments
builder_fn
- Function to configure the query builder
§Returns
Result containing the search response or an error
§Example
use serper_sdk::{SearchService, SearchQueryBuilder};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let _service = SearchService::new("demo-key-for-docs".to_string())?;
// Demonstrate the builder pattern structure
let query = SearchQueryBuilder::new()
.query("Hamze Ghalebi CTO at Remolab")
.location("Paris")
.page(1)
.build()?;
println!("Query built with search_with pattern: {}", query.q);
// In real async usage: service.search_with(|builder| { ... }).await?
Ok(())
}
Sourcepub fn info(&self) -> SearchServiceInfo
pub fn info(&self) -> SearchServiceInfo
Gets information about the current service configuration
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SearchService
impl !RefUnwindSafe for SearchService
impl Send for SearchService
impl Sync for SearchService
impl Unpin for SearchService
impl !UnwindSafe for SearchService
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