Crate rrhodium

Crate rrhodium 

Source
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§

FacetsConjunction
A collection of disjunctions that represents a logical AND operation (conjunction).
FacetsDisjunction
A collection of facets that represents a logical OR operation (disjunction).
QueryBuilder
A builder for constructing SearchType::Search instances with optional parameters.
SearchBuilder
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.

Enums§

Facets
A list specifying the different kinds of facets/filters that can be applied to queries.
HashingAlgo
Requirement
A list specifying the different kinds of requirements types.
SearchType
A list specifying the different kinds of requests based on the API routes.