Trait UnitsService

Source
pub trait UnitsService {
    // Required methods
    fn get_all_units(
        &self,
        auth_: BearerToken,
    ) -> Result<GetUnitsResponse, Error>;
    fn get_unit(
        &self,
        auth_: BearerToken,
        unit: UnitSymbol,
    ) -> Result<Option<Unit>, Error>;
    fn get_batch_units(
        &self,
        auth_: BearerToken,
        units: BTreeSet<UnitSymbol>,
    ) -> Result<BTreeMap<UnitSymbol, Unit>, Error>;
    fn get_commensurable_units(
        &self,
        auth_: BearerToken,
        unit: UnitSymbol,
    ) -> Result<BTreeSet<Unit>, Error>;
}
Expand description

The Units Service serves as a comprehensive catalog of the units of measurement supported by scout. Units, by default, follow the UCUM convention for representation.

Required Methods§

Source

fn get_all_units(&self, auth_: BearerToken) -> Result<GetUnitsResponse, Error>

Returns all known units, grouped by the physical property they measure.

Source

fn get_unit( &self, auth_: BearerToken, unit: UnitSymbol, ) -> Result<Option<Unit>, Error>

Returns information for a unit symbol if available. Returns as empty if the provided symbol cannot be parsed.

Source

fn get_batch_units( &self, auth_: BearerToken, units: BTreeSet<UnitSymbol>, ) -> Result<BTreeMap<UnitSymbol, Unit>, Error>

Returns information for the unit symbols if available. If the provided symbol cannot be parsed, it will be omitted from the map.

Source

fn get_commensurable_units( &self, auth_: BearerToken, unit: UnitSymbol, ) -> Result<BTreeSet<Unit>, Error>

Returns the set of cataloged units that can be converted to and from the given unit. No commensurable units does not imply the unit is invalid. Use /get-unit to check for validity.

Implementors§