Expand description
§rrhodium
rrhodium is a library focused in building urls for the modrinth API. Since it is a pain in
the ass to make them and specially the facets.
§Builder approach
The approach for bulding the urls is a BUILDER pattern (who could tell?), which I think it’s very nice. Also it is implemented with manual type-state so you can’t fuck it up and build urls without specifying a search type.
use rrhodium::*;
fn buzz() {
SearchBuilder::new().game_versions(vec!["1.19.2", "1.19.1"]).build_url()
}The above code WON’T compile, since it’s mising the search type.
§Facets approach
For the facets this library approachs the problem by using two structs:
FacetsConjunction and FacetsDisjunction, since they must be added in
CNF way.
use rrhodium::*;
fn foo() -> FacetsConjunction {
FacetsConjunction::new()
.and(FacetsDisjunction::new_with(Facets::Categories("Technology".to_string())))
.and(FacetsDisjunction::new_with(Facets::Categories("Magic".to_string())))
.and(
FacetsDisjunction::new_with(Facets::Version("1.19".to_string()))
.or(Facets::Version("1.19.1".to_string())),
)
}The above example means:
I want my search to show (whatever you are searching) only results which categories are “Technology” AND “Magic”, AND the version must be 1.19 OR 1.19.1.
Whatever is inside of every disjunction is an OR and everything that is inside a conjuntion is an AND.
For now only the getters routes are provided, and I don’t think I’ll add the others (create/delete/modify project)
Structs§
- Facets
Conjunction - A collection of disjunctions that represents a logical AND operation (conjunction).
- Facets
Disjunction - A collection of facets that represents a logical OR operation (disjunction).
- Query
Builder - A builder for constructing
SearchType::Searchinstances with optional parameters. - Search
Builder - A builder for building the URL with the indicated parameters
This struct works with
TypeStateProgramming so theSearchBuilder::build_url()method can’t be called unlesssearch_typeis set.
Enums§
- Facets
- A list specifying the different kinds of facets/filters that can be applied to queries.
- Hashing
Algo - Requirement
- A list specifying the different kinds of requirements types.
- Search
Type - A list specifying the different kinds of requests based on the API routes.