pub struct SearchBuilder<T = ()> { /* private fields */ }Expand description
A builder for building the URL with the indicated parameters
This struct works with TypeState Programming so the SearchBuilder::build_url() method
can’t be called unless search_type is set.
The facets field works as a conjunction (AND) of disjunctions (OR):
Implementations§
Source§impl SearchBuilder<()>
impl SearchBuilder<()>
pub fn new() -> SearchBuilder<()>
Source§impl<T> SearchBuilder<T>
impl<T> SearchBuilder<T>
Sourcepub fn facets(self, facets: impl Into<FacetsConjunction>) -> Self
pub fn facets(self, facets: impl Into<FacetsConjunction>) -> Self
Sets the facets.
Sourcepub fn game_versions<E>(self, versions: impl IntoIterator<Item = E>) -> Selfwhere
E: ToString,
pub fn game_versions<E>(self, versions: impl IntoIterator<Item = E>) -> Selfwhere
E: ToString,
Sets the game versions filter for the project version search.
§Parameters
versions: A type that can be iterated and its items implementsToString.
§Returns
Returns an updated instance of the SearchBuilder with the specified
game versions filter applied.
§Example
use rrhodium::*;
let builder = SearchBuilder::new()
.search_type(SearchType::ProjectVersion {id: "example_id".to_owned(), loaders:
Some(vec!["fabric".to_string()])})
.game_versions(["1.16.5", "1.17.1"])
.build_url();§Restrictions
This method is only available when the search type is ProjectVersion.
Attempting to call this method for other search types will do nothing.
§Panics
This method does not panic.
§Notes
- The
game_versionsparameter allows you to filter results to only include project versions compatible with the specified game versions. - Ensure that you are using this method within the
ProjectVersionsearch context, as it is specifically designed for filtering versions based on game compatibility.
Sourcepub fn add_game_version(self, version: impl ToString) -> Self
pub fn add_game_version(self, version: impl ToString) -> Self
Adds a single game version to the game versions filter for the project version search.
This method allows you to append a game version to the existing filter
criteria in the SearchBuilder. The version is added to the vector
of game versions that will be used to filter the results of the
search.
§Parameters
version: Whatever type that can be transformed into aString.
§Returns
Returns an updated instance of the SearchBuilder with the specified
game version added to the filter criteria.
§Example
use rrhodium::{SearchType, SearchBuilder};
let builder = SearchBuilder::new()
.search_type(SearchType::ProjectVersion {id: "example_id".to_string(), loaders: Some(vec!["fabric".to_string()])})
.add_game_version("1.16.5")
.add_game_version("1.17.1")
.build_url();§Restrictions
This method only has an effect when the search type is ProjectVersion.
If used with a different search type, it will have no impact on the
search builder and will silently ignore the call.
§Panics
This method does not panic.
§Errors
This method does not return errors.
§Notes
- Ensure that this method is called within the
ProjectVersionsearch context, as it is specifically designed for filtering project versions based on game compatibility. - If used outside the
ProjectVersioncontext, the method will not modify the builder and will effectively do nothing.
pub fn search_type(self, search_type: SearchType) -> SearchBuilder<SearchType>
Source§impl SearchBuilder<SearchType>
impl SearchBuilder<SearchType>
Sourcepub fn build_url(self) -> String
pub fn build_url(self) -> String
Generates the URL based on the SearchBuilder object.
This method constructs a URL for the Modrinth API using various
parameters from the SearchBuilder struct. It supports multiple
search types and query parameters, and it constructs the URL
accordingly.
§Returns
A String representing the constructed URL.
§Examples
use rrhodium::*;
let search_builder: String = SearchBuilder::new()
.search_type(QueryBuilder::new().limit(10).offset(5).build())
.build_url();
assert_eq!("https://api.modrinth.com/v2/search?limit=10&offset=5", &search_builder);Trait Implementations§
Source§impl<T: Default> Default for SearchBuilder<T>
impl<T: Default> Default for SearchBuilder<T>
Source§fn default() -> SearchBuilder<T>
fn default() -> SearchBuilder<T>
Auto Trait Implementations§
impl<T> Freeze for SearchBuilder<T>where
T: Freeze,
impl<T> RefUnwindSafe for SearchBuilder<T>where
T: RefUnwindSafe,
impl<T> Send for SearchBuilder<T>where
T: Send,
impl<T> Sync for SearchBuilder<T>where
T: Sync,
impl<T> Unpin for SearchBuilder<T>where
T: Unpin,
impl<T> UnwindSafe for SearchBuilder<T>where
T: UnwindSafe,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more