Skip to content

Commit

Permalink
Fix cargo clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh1nku committed Jul 1, 2024
1 parent fb552d1 commit 66db8b7
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion framework/src/clients/blocking_cloud_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl BlockingSolrCloudClient {
/// # Ok(())
/// # }
/// ```
pub fn collection_exists<'a, S: AsRef<str>>(&self, name: S) -> Result<bool, SolrError> {
pub fn collection_exists<S: AsRef<str>>(&self, name: S) -> Result<bool, SolrError> {
collection_exists_blocking(&self.context, name)
}

Expand Down
2 changes: 1 addition & 1 deletion framework/src/models/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl From<SolrServerContextBuilder> for SolrServerContext {
Self {
host: builder.host,
auth: builder.auth,
client: builder.client.unwrap_or_else(reqwest::Client::new),
client: builder.client.unwrap_or_default(),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions framework/src/models/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ where
Some(value_map) => {
let mut return_map: HashMap<String, Vec<String>> = HashMap::new();
for (key, values) in value_map {
if values.len() > 0 {
return_map.insert(key, values.split(",").map(|x| x.to_string()).collect());
if !values.is_empty() {
return_map.insert(key, values.split(',').map(|x| x.to_string()).collect());
} else {
return_map.insert(key, vec![]);
}
Expand Down
2 changes: 1 addition & 1 deletion framework/src/queries/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub fn get_collections_blocking<C: AsRef<SolrServerContext>>(
}

#[cfg(feature = "blocking")]
pub fn collection_exists_blocking<'a, C: AsRef<SolrServerContext>, S: AsRef<str>>(
pub fn collection_exists_blocking<C: AsRef<SolrServerContext>, S: AsRef<str>>(
context: C,
name: S,
) -> Result<bool, SolrError> {
Expand Down
6 changes: 2 additions & 4 deletions framework/src/queries/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::models::context::SolrServerContext;
use crate::models::error::{try_solr_error, SolrError};
use crate::models::error::SolrError;
use crate::queries::request_builder::SolrRequestBuilder;
use std::fs::File;
use std::io::{Read, Seek, Write};
Expand Down Expand Up @@ -63,13 +63,11 @@ pub async fn upload_config<C: AsRef<SolrServerContext>, S: AsRef<str>, P: AsRef<
let mut vec = Vec::new();
outfile.read_to_end(&mut vec)?;

let json = SolrRequestBuilder::new(context.as_ref(), "/solr/admin/configs")
let _ = SolrRequestBuilder::new(context.as_ref(), "/solr/admin/configs")
.with_query_params(query_params.as_ref())
.with_headers(vec![("Content-Type", "application/octet-stream")])
.send_post_with_body(vec)
.await?;

try_solr_error(&json)?;
Ok(())
}

Expand Down
14 changes: 7 additions & 7 deletions framework/src/queries/request_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use serde::{Deserialize, Serialize};

#[derive(Deserialize, Serialize, Debug, Copy, Clone)]
enum SolrRequestType {
GET,
POST,
Get,
Post,
}

pub struct SolrRequestBuilder<'a> {
Expand Down Expand Up @@ -49,7 +49,7 @@ impl<'a> SolrRequestBuilder<'a> {
let request = create_standard_request(
self.context,
self.url,
SolrRequestType::GET,
SolrRequestType::Get,
self.query_params,
self.headers.as_ref(),
)
Expand All @@ -68,7 +68,7 @@ impl<'a> SolrRequestBuilder<'a> {
let mut request = create_standard_request(
self.context,
self.url,
SolrRequestType::POST,
SolrRequestType::Post,
self.query_params,
self.headers.as_ref(),
)
Expand All @@ -88,7 +88,7 @@ impl<'a> SolrRequestBuilder<'a> {
let mut request = create_standard_request(
self.context,
self.url,
SolrRequestType::POST,
SolrRequestType::Post,
self.query_params,
self.headers.as_ref(),
)
Expand All @@ -110,12 +110,12 @@ async fn create_standard_request<'a>(
headers: Option<&Vec<(String, String)>>,
) -> Result<RequestBuilder, SolrError> {
let mut request = match request_type {
SolrRequestType::GET => {
SolrRequestType::Get => {
context
.client
.get(format!("{}{}", context.host.get_solr_node().await?, url))
}
SolrRequestType::POST => {
SolrRequestType::Post => {
context
.client
.post(format!("{}{}", context.host.get_solr_node().await?, url))
Expand Down
2 changes: 1 addition & 1 deletion wrappers/python/src/models/facet_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl SolrPivotFacetResultWrapper {
}

pub fn get_pivots(&self) -> Vec<SolrPivotFacetResultWrapper> {
self.0.get_pivots().into_iter().map(|x| x.into()).collect()
self.0.get_pivots().iter().map(|x| x.into()).collect()
}

pub fn get_queries(&self) -> HashMap<String, usize> {
Expand Down
6 changes: 3 additions & 3 deletions wrappers/python/src/models/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ impl SolrGroupResultWrapper {
pub fn get_field_result(&self) -> Option<Vec<SolrGroupFieldResultWrapper>> {
self.0
.get_field_result()
.map(|v| v.into_iter().map(|v| v.to_owned().into()).collect())
.map(|v| v.iter().map(|v| v.to_owned().into()).collect())
}

pub fn get_query_result(&self) -> PyResult<Option<SolrDocsResponseWrapper>> {
match self.0.get_query_result() {
Some(v) => Ok(Some(SolrDocsResponseWrapper::try_from(v.to_owned())?)),
Some(v) => Ok(Some(SolrDocsResponseWrapper::from(v.to_owned()))),
None => Ok(None),
}
}

pub fn get_simple_result(&self) -> PyResult<Option<SolrDocsResponseWrapper>> {
match self.0.get_simple_result() {
Some(v) => Ok(Some(SolrDocsResponseWrapper::try_from(v.to_owned())?)),
Some(v) => Ok(Some(SolrDocsResponseWrapper::from(v.to_owned()))),
None => Ok(None),
}
}
Expand Down
2 changes: 1 addition & 1 deletion wrappers/python/src/models/json_facet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl SolrJsonFacetResponseWrapper {
pub fn get_buckets(&self) -> Vec<SolrJsonFacetResponseWrapper> {
self.0
.get_buckets()
.map(|bucket| SolrJsonFacetResponseWrapper::from(bucket))
.map(SolrJsonFacetResponseWrapper::from)
.collect()
}

Expand Down
6 changes: 2 additions & 4 deletions wrappers/python/src/models/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ impl SolrDocsResponseWrapper {
.0
.get_docs::<serde_json::Value>()
.map_err(PyErrWrapper::from)?;
let vec = docs
.into_iter()
docs.into_iter()
.map(|doc| pythonize(py, &doc).map_err(PyErrWrapper::from))
.collect::<Result<Vec<_>, _>>();
vec
.collect::<Result<Vec<_>, _>>()
})
.map_err(|e| e.into())
}
Expand Down
12 changes: 5 additions & 7 deletions wrappers/python/src/queries/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn create_alias(
) -> PyResult<Bound<PyAny>> {
pyo3_asyncio::tokio::future_into_py(py, async move {
let context: SolrServerContext = context.into();
let result = create_alias_rs(
Ok(create_alias_rs(
&context,
name.as_str(),
collections
Expand All @@ -68,8 +68,7 @@ pub fn create_alias(
.as_slice(),
)
.await
.map_err(PyErrWrapper::from)?;
Ok(result)
.map_err(PyErrWrapper::from)?)
})
}

Expand All @@ -82,7 +81,7 @@ pub fn create_alias_blocking(
) -> PyResult<()> {
py.allow_threads(move || {
let context: SolrServerContext = context.into();
let result = create_alias_blocking_rs(
Ok(create_alias_blocking_rs(
&context,
name.as_str(),
collections
Expand All @@ -91,8 +90,7 @@ pub fn create_alias_blocking(
.collect::<Vec<_>>()
.as_slice(),
)
.map_err(PyErrWrapper::from)?;
Ok(result)
.map_err(PyErrWrapper::from)?)
})
}

Expand Down Expand Up @@ -136,7 +134,7 @@ pub fn delete_alias(
delete_alias_rs(&context, name.as_str())
.await
.map_err(PyErrWrapper::from)?;
Ok(Python::with_gil(|_| ()))
Ok(())
})
}

Expand Down
4 changes: 2 additions & 2 deletions wrappers/python/src/queries/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn create_collection(
) -> PyResult<Bound<PyAny>> {
pyo3_asyncio::tokio::future_into_py(py, async move {
let context: SolrServerContext = context.into();
let result = create_collection_rs(
create_collection_rs(
&context,
name.as_str(),
config.as_str(),
Expand All @@ -47,7 +47,7 @@ pub fn create_collection(
)
.await
.map_err(PyErrWrapper::from)?;
Ok(Python::with_gil(|_| result))
Ok(())
})
}

Expand Down
1 change: 1 addition & 0 deletions wrappers/python/src/queries/components/facet_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ pub struct FieldFacetEntryWrapper(FieldFacetEntry);
#[pymethods]
impl FieldFacetEntryWrapper {
#[new]
#[allow(clippy::too_many_arguments)]
pub fn new(
field: String,
prefix: Option<String>,
Expand Down
1 change: 1 addition & 0 deletions wrappers/python/src/queries/components/grouping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ impl From<GroupFormatting> for GroupFormattingWrapper {
#[pymethods]
impl GroupingComponentWrapper {
#[new]
#[allow(clippy::too_many_arguments)]
pub fn new(
fields: Option<Vec<String>>,
queries: Option<Vec<String>>,
Expand Down
1 change: 1 addition & 0 deletions wrappers/python/src/queries/components/json_facet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ pub struct JsonQueryFacetWrapper {}
#[pymethods]
impl JsonQueryFacetWrapper {
#[new]
#[allow(clippy::too_many_arguments)]
fn new(
q: String,
limit: Option<usize>,
Expand Down
8 changes: 4 additions & 4 deletions wrappers/python/src/queries/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ pub fn upload_config(
) -> PyResult<Bound<PyAny>> {
pyo3_asyncio::tokio::future_into_py(py, async move {
let context: SolrServerContext = context.into();
let result = upload_config_rs(&context, name.as_str(), path.as_path())
upload_config_rs(&context, name.as_str(), path.as_path())
.await
.map_err(PyErrWrapper::from)?;
Ok(Python::with_gil(|_| result))
Ok(())
})
}

Expand Down Expand Up @@ -117,10 +117,10 @@ pub fn delete_config(
) -> PyResult<Bound<PyAny>> {
pyo3_asyncio::tokio::future_into_py(py, async move {
let context: SolrServerContext = context.into();
let result = delete_config_rs(&context, name.as_str())
delete_config_rs(&context, name.as_str())
.await
.map_err(PyErrWrapper::from)?;
Ok(Python::with_gil(|_| result))
Ok(())
})
}

Expand Down
2 changes: 2 additions & 0 deletions wrappers/python/src/queries/def_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ pub struct DismaxQueryWrapper {}
#[pymethods]
impl DismaxQueryWrapper {
#[new]
#[allow(clippy::too_many_arguments)]
pub fn new(
q_alt: Option<String>,
qf: Option<String>,
Expand Down Expand Up @@ -124,6 +125,7 @@ pub struct EdismaxQueryWrapper {}
#[pymethods]
impl EdismaxQueryWrapper {
#[new]
#[allow(clippy::too_many_arguments)]
pub fn new(
q_alt: Option<String>,
qf: Option<String>,
Expand Down
1 change: 1 addition & 0 deletions wrappers/python/src/queries/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct SelectQueryWrapper(SelectQuery);
#[pymethods]
impl SelectQueryWrapper {
#[new]
#[allow(clippy::too_many_arguments)]
fn new(
q: Option<String>,
fl: Option<Vec<String>>,
Expand Down

0 comments on commit 66db8b7

Please sign in to comment.