api-peers
Source: crates/lvcs-api/src/peers.rs.
/// `peer.list` (decision 303): the peers this project's swarm is
/// connected to now.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub struct PeerListParams {}
/// `peer.list` result, sorted by peer.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PeerListResult {
#[serde(default)]
pub peers: Vec<PeerEntry>,
}
/// One connected peer.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PeerEntry {
/// Its libp2p peer id. An API value only, never a telemetry value.
pub peer: String,
/// When its first connection of this daemon's run came up, in Unix
/// milliseconds by this daemon's clock.
pub since_ms: i64,
/// Its machine name, as its own inventory says (decision 314).
#[serde(default, skip_serializing_if = "Option::is_none")]
pub host: Option<String>,
/// The participants this daemon saw sign from the peer's device, and
/// those its daemon holds, each signature checked (decision 314), by
/// name (`Named`), sorted.
#[serde(default)]
pub participants: Vec<String>,
/// Its roles, sorted: `runner` when one of its participants carries
/// runs this daemon heard of.
#[serde(default)]
pub roles: Vec<PeerRole>,
}
/// A role a peer plays in the project.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum PeerRole {
/// One of its participants runs actions.
Runner,
}
/// `presence.list` (decision 303): every participant the coord actor
/// counts as present, on a document or in a workspace, until
/// `PRESENCE_TTL_SECS` after its latest presence.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub struct PresenceListParams {}
/// `presence.list` result, newest first.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PresenceListResult {
#[serde(default)]
pub presences: Vec<PresenceEntry>,
}
/// One participant's presence.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PresenceEntry {
/// Its participant id, in `ID_ENCODING`.
pub participant: String,
/// Its name (`Named`).
pub name: String,
/// The document it is on, if any.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub address: Option<String>,
/// The workspace it is in, by id (`ID_ENCODING`), if any.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub workspace: Option<String>,
/// Its signed time, in Unix milliseconds.
pub at_ms: i64,
}
/// Server push, JSON-RPC notification method `presence` (`watch`).
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PresencePush {
/// The `watch` it is pushed for.
pub sub: u64,
pub presence: PresenceEntry,
}