Skip to main content

surrealdb_expr/expr/
changefeed.rs

1use std::time;
2
3use revision::revisioned;
4
5use crate::expr::statements::info::InfoStructure;
6use crate::val::{Duration, Value};
7
8#[revisioned(revision = 1)]
9#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
10#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
11pub struct ChangeFeed {
12	pub expiry: time::Duration,
13	pub store_diff: bool,
14}
15
16impl Default for ChangeFeed {
17	fn default() -> Self {
18		Self {
19			expiry: time::Duration::from_secs(0),
20			store_diff: false,
21		}
22	}
23}
24
25impl InfoStructure for ChangeFeed {
26	fn structure(self) -> Value {
27		Value::from(map! {
28			"expiry" => Duration(self.expiry).into(),
29			"original" => self.store_diff.into(),
30		})
31	}
32}