Changeset - 5137b1060291
[Not reviewed]
0 1 0
Christopher Esterhuyse - 5 years ago 2020-02-05 17:31:06
christopheresterhuyse@gmail.com
api
1 file changed with 4 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/common.rs
Show inline comments
 
@@ -41,27 +41,26 @@ pub enum Polarity {
 
    Getter, // input port (from the perspective of the component)
 
}
 

	
 
#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Copy, Clone, Debug)]
 
pub struct Key(u64);
 

	
 
pub enum NewMainErr {
 
pub enum MainComponentErr {
 
    NoSuchComponent,
 
    NonPortTypeParameters,
 
    WrongNumberOfArguments { expected: usize },
 
    WrongPortPolarity { index: usize },
 
}
 
pub trait ProtocolDescription: Sized {
 
    type S: ComponentState<D = Self>;
 

	
 
    fn parse(pdl: &[u8]) -> Result<Self, String>;
 
    fn component_polarities(&self, identifier: &[u8]) -> Result<Vec<Polarity>, MainComponentErr>;
 
    fn new_main_component(
 
        &self,
 
        identifier: &[u8],
 
        ports: &[(Polarity, Key)],
 
    ) -> Result<Self::S, NewMainErr>;
 
        ports: &[Key],
 
    ) -> Result<Self::S, MainComponentErr>;
 
}
 

	
 
pub trait ComponentState: Sized + Clone {
 
    type D: ProtocolDescription;
 
    fn pre_sync_run<C: MonoContext<D = Self::D, S = Self>>(
 
        &mut self,
0 comments (0 inline, 0 general)