@@ -46,6 +46,16 @@ pub trait ChiselModule<'a> {
4646
4747 /// Borrows the instance as a trait object.
4848 fn as_abstract ( & ' a self ) -> Self :: ObjectReference ;
49+
50+ // Create instance with default settings.
51+ fn with_defaults ( ) -> Result < Self , ModuleError >
52+ where
53+ Self : Sized ;
54+
55+ // Create instance with a specific configuration.
56+ fn with_config ( config : & HashMap < String , String > ) -> Result < Self , ModuleError >
57+ where
58+ Self : Sized ;
4959}
5060
5161pub trait ModuleCreator {
@@ -66,23 +76,13 @@ pub trait ModuleValidator {
6676 fn validate ( & self , module : & Module ) -> Result < bool , ModuleError > ;
6777}
6878
79+ // TODO: remove this
6980pub trait ModulePreset {
7081 fn with_preset ( preset : & str ) -> Result < Self , ModuleError >
7182 where
7283 Self : std:: marker:: Sized ;
7384}
7485
75- // TODO: move this to be part of ChiselModule and retire ModulePreset
76- pub trait ModuleConfig {
77- fn with_defaults ( ) -> Result < Self , ModuleError >
78- where
79- Self : std:: marker:: Sized ;
80-
81- fn with_config ( config : & HashMap < String , String > ) -> Result < Self , ModuleError >
82- where
83- Self : std:: marker:: Sized ;
84- }
85-
8686impl From < String > for ModuleError {
8787 fn from ( error : String ) -> Self {
8888 ModuleError :: Custom ( error)
@@ -177,6 +177,14 @@ mod tests {
177177 fn as_abstract ( & ' a self ) -> Self :: ObjectReference {
178178 self as Self :: ObjectReference
179179 }
180+
181+ fn with_defaults ( ) -> Result < Self , ModuleError > {
182+ Err ( ModuleError :: NotSupported )
183+ }
184+
185+ fn with_config ( _config : & HashMap < String , String > ) -> Result < Self , ModuleError > {
186+ Err ( ModuleError :: NotSupported )
187+ }
180188 }
181189
182190 #[ test]
0 commit comments