surrealpatch/core/src/sql/edges.rs
Raphael Darley 4c8c9f6c8a
Info structure refactor (#3886)
Co-authored-by: Micha de Vries <micha@devrie.sh>
2024-04-17 15:27:55 +01:00

29 lines
846 B
Rust

use crate::sql::dir::Dir;
use crate::sql::table::Tables;
use crate::sql::thing::Thing;
use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Edges";
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[serde(rename = "$surrealdb::private::sql::Edges")]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Edges {
pub dir: Dir,
pub from: Thing,
pub what: Tables,
}
impl fmt::Display for Edges {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.what.len() {
0 => write!(f, "{}{}?", self.from, self.dir,),
1 => write!(f, "{}{}{}", self.from, self.dir, self.what),
_ => write!(f, "{}{}({})", self.from, self.dir, self.what),
}
}
}