use std::rc::Rc; use hn_api::types::{Comment, Item, Job, Poll, Pollopt, Story, User}; use trustfall::provider::TrustfallEnumVertex; #[derive(Debug, Clone, TrustfallEnumVertex)] pub enum Vertex { Story(Rc), Job(Rc), Comment(Rc), Poll(Rc), PollOption(Rc), User(Rc), } impl From for Vertex { fn from(item: Item) -> Self { match item { Item::Story(x) => Self::Story(x.into()), Item::Comment(x) => Self::Comment(x.into()), Item::Job(x) => Self::Job(x.into()), Item::Poll(x) => Self::Poll(x.into()), Item::Pollopt(x) => Self::PollOption(x.into()), } } } impl From for Vertex { fn from(c: Comment) -> Self { Self::Comment(Rc::from(c)) } } impl From for Vertex { fn from(u: User) -> Self { Self::User(Rc::from(u)) } }