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