use errors::Result;
use std::borrow::Cow;
use std::cmp;
use std::fmt;
use std::hash;
use {Loc, RpEndpoint, RpEnumType, 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<'a>(&'a self) -> Result<Cow<'a, 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;
type EnumType: fmt::Debug + Clone + cmp::Eq;
}
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Hash)]
pub struct CoreFlavor;
impl Flavor for CoreFlavor {
type Type = RpType<CoreFlavor>;
type Name = Loc<RpName<CoreFlavor>>;
type Field = RpField<CoreFlavor>;
type Endpoint = RpEndpoint<CoreFlavor>;
type Package = RpVersionedPackage;
type EnumType = RpEnumType;
}