1use errors::Result;
4use std::borrow::Cow;
5use std::cmp;
6use std::fmt;
7use std::hash;
8use {Loc, RpEndpoint, RpEnumType, RpField, RpName, RpPackage, RpType, RpVersionedPackage};
9
10pub trait FlavorField: fmt::Debug + Clone {
11 fn is_discriminating(&self) -> bool;
13}
14
15pub trait AsPackage
16where
17 Self: Sized,
18{
19 fn try_as_package<'a>(&'a self) -> Result<Cow<'a, RpPackage>>;
21
22 fn prefix_with(self, prefix: RpPackage) -> Self;
24}
25
26pub trait Flavor: fmt::Debug + Clone + cmp::Eq + hash::Hash {
28 type Type: fmt::Debug + Clone + cmp::Eq;
30 type Name: fmt::Display + fmt::Debug + Clone + cmp::Eq;
32 type Field: FlavorField;
34 type Endpoint: fmt::Debug + Clone;
36 type Package: fmt::Debug + Clone + cmp::Eq + cmp::Ord + hash::Hash + AsPackage;
38 type EnumType: fmt::Debug + Clone + cmp::Eq;
40}
41
42#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Hash)]
44pub struct CoreFlavor;
45
46impl Flavor for CoreFlavor {
47 type Type = RpType<CoreFlavor>;
48 type Name = Loc<RpName<CoreFlavor>>;
49 type Field = RpField<CoreFlavor>;
50 type Endpoint = RpEndpoint<CoreFlavor>;
51 type Package = RpVersionedPackage;
52 type EnumType = RpEnumType;
53}