drmem_api/types/device/
mod.rs

1//! Defines types related to devices.
2
3use std::{pin::Pin, time};
4use tokio_stream::Stream;
5
6mod value;
7pub use value::Value;
8
9/// Represents the value of a device at a specific moment.
10///
11/// When a client monitors a device, it receives a stream of readings
12/// as the device gets updated. A reading consists of the value of the
13/// device along with the timestamp. The set of types that a device
14/// can return is defined in the `Value` type. The timestamp is given
15/// in UTC.
16#[derive(Debug, PartialEq, Clone)]
17pub struct Reading {
18    pub ts: time::SystemTime,
19    pub value: Value,
20}
21
22/// Generic type describing a stream of types.
23///
24/// Specializations of this type are used in various layers of
25/// `drmemd`. The drivers, for instance, provide a stream of `Reading`
26/// types. The GraphQL layer converts it into a stream of replies.
27pub type DataStream<T> = Pin<Box<dyn Stream<Item = T> + Send>>;
28
29mod name;
30pub use name::Base;
31pub use name::Name;
32pub use name::Path;