surrealpatch/core/src/sql/v2/changefeed.rs

33 lines
743 B
Rust
Raw Normal View History

use crate::sql::duration::Duration;
use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Formatter};
use std::str;
use std::time;
2023-08-18 22:51:56 +00:00
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 2)]
pub struct ChangeFeed {
pub expiry: time::Duration,
#[revision(start = 2)]
pub store_original: bool,
}
impl Display for ChangeFeed {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "CHANGEFEED {}", Duration(self.expiry))?;
if self.store_original {
write!(f, " INCLUDE ORIGINAL")?;
};
Ok(())
}
}
impl Default for ChangeFeed {
fn default() -> Self {
Self {
expiry: time::Duration::from_secs(0),
store_original: false,
}
}
}