api-watch
Source: crates/lvcs-api/src/watch.rs.
/// `watch` (decision 303): subscribe this connection to `pushes`, each a
/// `push_kind` value that `watch` takes (`channel_moved`, `run`,
/// `presence`, `activity`); any other is invalid params. It lasts until
/// the connection closes.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub struct WatchParams {
pub pushes: Vec<String>,
}
/// `watch` result; its pushes carry the same id.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct WatchResult {
pub sub: u64,
}
/// The `push_kind` value a `watch` names, when `watch` takes it.
pub fn watched(name: &str) -> Option<PushKind> {
use lvcs_vocab::Vocabulary as _;
PushKind::ALL
.iter()
.copied()
.find(|kind| kind.as_str() == name)
.filter(|kind| kind.watched())
}
/// Server push, JSON-RPC notification method `channel_moved` (`watch`):
/// a channel's or combination's value moved.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ChannelMovedPush {
/// The `watch` it is pushed for.
pub sub: u64,
pub channel: String,
/// Its new value's frontier ids (`ID_ENCODING`), sorted; empty for
/// none.
pub frontiers: Vec<String>,
}
/// Server push, JSON-RPC notification method `activity` (`watch`):
/// something happened in the project, metadata only.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ActivityPush {
/// The `watch` it is pushed for.
pub sub: u64,
pub activity: Activity,
}
/// One project event, metadata only (decision 303).
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Activity {
/// An `activity_kind` value.
#[serde(serialize_with = "vocab_to", deserialize_with = "vocab_from")]
pub kind: ActivityKind,
/// When, in Unix milliseconds: the signed time when it has one, else
/// this daemon's clock.
pub at_ms: i64,
/// Who, by name (`Named`), when a participant did it.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub by: Option<String>,
/// The document it concerns, if any.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub address: Option<String>,
/// The channel it concerns, if any.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub channel: Option<String>,
/// The workspace it concerns, by name, if any.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub workspace: Option<String>,
/// The peer it concerns (`peer_joined`, `peer_left`), if any.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub peer: Option<String>,
}