pub struct Record {
pub envelope: Envelope,
pub change: Change,
}Expand description
One line of the log: its envelope and its change.
Fields§
§envelope: Envelope§change: ChangeImplementations§
Source§impl Record
impl Record
Sourcepub fn other(&self) -> Option<&'static str>
pub fn other(&self) -> Option<&'static str>
The field of this record whose value this build read as other:
by, scope, reason, the kind or the to of a message, or
a session URI (session, or the from of a message). None
when the build knows each value. A record with such a
value counts as a skipped record: the build writes no checkpoint
past it (01M3XM2C18TT8VSKGD77YPZG53).
use riff_core::record::{Change, Line};
let read = |line: &str| match Line::parse(line).unwrap() {
Line::Record(record) => record,
Line::Unknown { .. } => panic!("a known kind"),
};
let known = r#"{"position":2,"written_at_ms":1,"by":{"person":"ann"},"command":"pause","change":{"pause_set":{"scope":"riff","state":"paused"}}}"#;
assert_eq!(read(known).other(), None);
assert_eq!(read(known).change.kind(), "pause_set");
assert!(Change::KINDS.contains(&"pause_set"));
// The values of a later build.
assert_eq!(read(&known.replace(r#""riff""#, r#"{"wave":"17"}"#)).other(), Some("scope"));
assert_eq!(read(&known.replace(r#""riff""#, r#""host""#)).other(), Some("scope"));
assert_eq!(read(&known.replace("person", "robot")).other(), Some("by"));
// The state of a pause has no `other`: the line does not read.
assert!(Line::parse(&known.replace(r#""paused""#, r#""slow""#)).is_err());
// A message of a later build: a kind, and a field of a selector.
let post = r#"{"position":3,"written_at_ms":1,"change":{"posted":{"thread":"acme/app","message":{"seq":1,"from":"riff://ann@heron/acme/app?session=s1","to":[{"user":"bob"}],"body":"hi","at_ms":1,"kind":"note"}}}}"#;
assert_eq!(read(post).other(), None);
assert_eq!(read(&post.replace("note", "poll")).other(), Some("kind"));
assert_eq!(read(&post.replace(r#"{"user":"bob"}"#, r#"{"user":"bob","wave":"17"}"#)).other(), Some("to"));
assert_eq!(read(&post.replace(r#"{"user":"bob"}"#, r#""all""#)).other(), Some("to"));
// A session URI with a query part of a later build.
assert_eq!(read(&post.replace("session=s1", "session=s1&wave=17")).other(), Some("from"));Source§impl Record
impl Record
Sourcepub fn of_repository(&self, repo: &ThreadName) -> bool
pub fn of_repository(&self, repo: &ThreadName) -> bool
True when this record is a record of the repository thread repo
for an audit (01M3ZWRC11R5M9V1KTF05P240W): a post, a
membership, a lead, a claim or a release in that thread; a direct
message from a session in that repository; the start or the end
of a session in that repository; and a pause of the riff or of
that repository. Each other record is not.
use riff_core::record::{Change, Claimed, Envelope, Line, PauseSet, Record, Scope};
use riff_core::wire::RiffState;
let repo = "acme/app".parse()?;
let envelope = Envelope { position: 1, written_at_ms: 1, by: None, command: None, call: None };
let record = |change| Record { envelope: envelope.clone(), change };
let claim = |thread: &str| record(Change::Claimed(Claimed {
session: "riff://ann@heron/acme/app?session=s1".parse().unwrap(),
thread: thread.parse().unwrap(),
item: "issue-7".into(),
}));
assert!(claim("acme/app").of_repository(&repo));
assert!(!claim("acme/web").of_repository(&repo));
let pause = |scope| record(Change::PauseSet(PauseSet { scope, state: RiffState::Paused }));
assert!(pause(Scope::Riff).of_repository(&repo));
assert!(pause(Scope::Repository(repo.clone())).of_repository(&repo));
assert!(!pause(Scope::Repository("acme/web".parse()?)).of_repository(&repo));
// A record of the people is not a record of a repository.
let invited = r#"{"position":7,"written_at_ms":1,"change":{"member_invited":{"email":"ann@acme.io"}}}"#;
let Line::Record(invited) = Line::parse(invited)? else { panic!("a known kind") };
assert!(!invited.of_repository(&repo));Sourcepub fn for_audit(self) -> Record
pub fn for_audit(self) -> Record
This record for an audit: a post has only its mark
(Posted::for_audit). Each other record stays as it is.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Record
impl<'de> Deserialize<'de> for Record
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Record
impl JsonSchema for Record
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreimpl Eq for Record
impl StructuralPartialEq for Record
Auto Trait Implementations§
impl Freeze for Record
impl RefUnwindSafe for Record
impl Send for Record
impl Sync for Record
impl Unpin for Record
impl UnsafeUnpin for Record
impl UnwindSafe for Record
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.