4 #![feature(rustc_private)]
6 extern crate rustc_serialize;
8 use rustc_serialize::{json, Decodable, Encodable};
11 pub trait Entity: Decodable<json::Decoder> + for<'a> Encodable<json::Encoder<'a>> + Sized {
13 + Decodable<json::Decoder>
14 + for<'a> Encodable<json::Encoder<'a>>
21 fn id(&self) -> Self::Key;
23 fn find_by_id(id: Self::Key) -> Option<Self>;
26 pub struct DbRef<E: Entity> {
34 fn get(self) -> Option<E> {
35 E::find_by_id(self.id)