29 lines
846 B
Rust
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),
|
|
}
|
|
}
|
|
}
|