Skip to main content

fetch_active

Function fetch_active 

Source
pub fn fetch_active(
    http_base: &str,
    trust: &Trust,
) -> Result<Preferences, ClientError>
Expand description

Asks the server what it currently prefers, and reads as much of the answer as [signalk::units::Preferences::parse] recognises.

Never answers with an error over a preference merely not stated, or stated in a unit this crate does not convert – see [signalk::units::Preferences::parse]’s own doc; those read as an ordinary, empty [signalk::units::Preferences], the state a caller already has to fall back to its own default unit for regardless.

§Errors

If the server cannot be reached at all, or answers something that is not JSON – an older signalk-server with no unitpreferences feature answers 404, which surfaces here rather than being swallowed, since it is a caller’s own decision whether that is worth logging.