pub struct SearchParams {
pub query: String,
pub fields: Vec<String>,
}Expand description
Query parameters for full-text search on a collection endpoint.
query is the search string. fields optionally scopes the search
to specific fields; when omitted the backend decides which fields to search.
{"query": "annual report", "fields": ["title", "description"]}Fields§
§query: StringThe search string. Must not exceed 500 characters.
fields: Vec<String>Optional list of field names to scope the search to.
Implementations§
Source§impl SearchParams
impl SearchParams
Sourcepub fn new(query: impl Into<String>) -> Self
pub fn new(query: impl Into<String>) -> Self
Create search params targeting all fields.
§Examples
use api_bones::query::SearchParams;
let s = SearchParams::new("annual report");
assert_eq!(s.query, "annual report");
assert!(s.fields.is_empty());Sourcepub fn try_new(query: impl Into<String>) -> Result<Self, ValidationError>
pub fn try_new(query: impl Into<String>) -> Result<Self, ValidationError>
Create validated search params — enforces 1–500 char constraint without validator feature.
§Examples
use api_bones::query::SearchParams;
let s = SearchParams::try_new("annual report").unwrap();
assert_eq!(s.query, "annual report");
assert!(SearchParams::try_new("").is_err());
assert!(SearchParams::try_new("a".repeat(501)).is_err());Sourcepub fn try_with_fields(
query: impl Into<String>,
fields: impl IntoIterator<Item = impl Into<String>>,
) -> Result<Self, ValidationError>
pub fn try_with_fields( query: impl Into<String>, fields: impl IntoIterator<Item = impl Into<String>>, ) -> Result<Self, ValidationError>
Create validated search params scoped to specific fields.
§Examples
use api_bones::query::SearchParams;
let s = SearchParams::try_with_fields("report", ["title"]).unwrap();
assert_eq!(s.fields, vec!["title"]);
assert!(SearchParams::try_with_fields("", ["title"]).is_err());Sourcepub fn with_fields(
query: impl Into<String>,
fields: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_fields( query: impl Into<String>, fields: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Create search params scoped to specific fields.
§Examples
use api_bones::query::SearchParams;
let s = SearchParams::with_fields("report", ["title", "description"]);
assert_eq!(s.query, "report");
assert_eq!(s.fields, vec!["title", "description"]);Trait Implementations§
Source§impl Clone for SearchParams
impl Clone for SearchParams
Source§fn clone(&self) -> SearchParams
fn clone(&self) -> SearchParams
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 moreSource§impl Debug for SearchParams
impl Debug for SearchParams
Source§impl<'de> Deserialize<'de> for SearchParams
impl<'de> Deserialize<'de> for SearchParams
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for SearchParams
impl PartialEq for SearchParams
Source§impl Serialize for SearchParams
impl Serialize for SearchParams
Source§impl Validate for SearchParams
impl Validate for SearchParams
Source§impl<'v_a> ValidateArgs<'v_a> for SearchParams
impl<'v_a> ValidateArgs<'v_a> for SearchParams
impl Eq for SearchParams
impl StructuralPartialEq for SearchParams
Auto Trait Implementations§
impl Freeze for SearchParams
impl RefUnwindSafe for SearchParams
impl Send for SearchParams
impl Sync for SearchParams
impl Unpin for SearchParams
impl UnsafeUnpin for SearchParams
impl UnwindSafe for SearchParams
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