Skip to main content

Crate archiver

Crate archiver 

Source
Expand description

A client for the EPICS Archiver Appliance retrieval API.

The pieces are split so that a browser build could reuse everything but the HTTP: ArchiverClient builds the request URLs (*_url), the parse_* functions decode the bodies, and the blocking get_data/search/metadata methods do both over ureq on native targets. In a browser those methods fail at once.

Times are UTC seconds since the Unix epoch as f64 (sub-microsecond resolution for current dates), the same as bobview’s trend and archiveview’s plot.

See DESIGN.md at the repository root for the wire format and its surprises (bare NaN tokens, string PREC, [ ] for no data, binned [mean, std, min, max, count] values from optimized_N).

Structs§

ArchiverClient
An Archiver Appliance retrieval service. Cheap to clone; holds no connection state, so it can be shared freely between threads and between several plots.
Meta
The meta object of a response, with the common fields decoded. Values may arrive as strings or numbers; both are accepted.
PvInfo
What getMetadata says about a PV (all optional: servers differ).
Query
A getData.json request.
Sample
One plotted point of archived data.
Search
A getMatchingPVs request.
TimeSeries
One PV’s archived data for a request.

Enums§

Error
Why a request failed.
Operator
Server-side processing for a data request.
SearchMode
How a search pattern is matched.
Severity
An archived alarm severity (the severity field: 0..=3).
ValueKind
What the archived values were, as seen in the response.

Constants§

DEFAULT_SEARCH_LIMIT
The default number of PV names a search asks for.
MAX_BINS
The most bins an optimized_N request asks for, whatever the plot width.

Functions§

format_time
t (UTC epoch seconds) as YYYY-MM-DDTHH:MM:SS.mmmZ, rounded to the millisecond. Non-finite or out-of-range times are clamped to the epoch and to year 9999.
parse_data
Decode a getData.json body: one TimeSeries per PV, empty for [ ]. Tolerates bare NaN/Infinity/-Infinity, string or numeric PREC/LOPR/HOPR, unknown keys, and fields objects. A severity-3 sample whose fields hold cnxlostepsecs becomes a Sample::gap. A 5-element array val on a scalar PV is an optimized bin (binned = true); other arrays are waveforms (val holds element 0).
parse_metadata
Decode a getMetadata body.
parse_names
Decode a JSON array of PV names (getMatchingPVs, getAllPVs).
parse_time
An archiver timestamp (Instant.parse / ISO offset forms, e.g. 2024-01-02T03:04:05.123Z or 2024-01-02T03:04:05-07:00) as epoch seconds.
parse_version
Decode a getVersion body: {"version": "..."}.
regex_escape
text with every regex metacharacter backslash-escaped, so it matches itself (in Java’s regex syntax, which the appliance uses, and in Rust’s).
sanitize_json
Replace the bare tokens NaN, Infinity and -Infinity outside strings with null, so serde_json accepts the body. Borrowed when there are none.

Type Aliases§

Result