@@ -49,6 +49,7 @@ pub struct ModuleBuilder<'a> {
49
49
pub ( crate ) functions : Vec < FunctionBuilder < ' a > > ,
50
50
pub ( crate ) constants : Vec < ( String , Box < dyn IntoConst + Send > , DocComments ) > ,
51
51
pub ( crate ) classes : Vec < fn ( ) -> ClassBuilder > ,
52
+ pub ( crate ) interfaces : Vec < fn ( ) -> ClassBuilder > ,
52
53
#[ cfg( feature = "enum" ) ]
53
54
pub ( crate ) enums : Vec < fn ( ) -> EnumBuilder > ,
54
55
startup_func : Option < StartupShutdownFunc > ,
@@ -179,7 +180,7 @@ impl ModuleBuilder<'_> {
179
180
///
180
181
/// * Panics if a constant could not be registered.
181
182
pub fn interface < T : RegisteredClass > ( mut self ) -> Self {
182
- self . classes . push ( || {
183
+ self . interfaces . push ( || {
183
184
let mut builder = InterfaceBuilder :: new ( T :: CLASS_NAME ) ;
184
185
for ( method, flags) in T :: method_builders ( ) {
185
186
builder = builder. method ( method, flags) ;
@@ -279,6 +280,7 @@ impl ModuleBuilder<'_> {
279
280
pub struct ModuleStartup {
280
281
constants : Vec < ( String , Box < dyn IntoConst + Send > ) > ,
281
282
classes : Vec < fn ( ) -> ClassBuilder > ,
283
+ interfaces : Vec < fn ( ) -> ClassBuilder > ,
282
284
#[ cfg( feature = "enum" ) ]
283
285
enums : Vec < fn ( ) -> EnumBuilder > ,
284
286
}
@@ -303,6 +305,10 @@ impl ModuleStartup {
303
305
c. register ( ) . expect ( "Failed to build class" ) ;
304
306
} ) ;
305
307
308
+ self . interfaces . into_iter ( ) . map ( |c| c ( ) ) . for_each ( |c| {
309
+ c. register ( ) . expect ( "Failed to build interface" ) ;
310
+ } ) ;
311
+
306
312
#[ cfg( feature = "enum" ) ]
307
313
self . enums
308
314
. into_iter ( )
@@ -345,6 +351,7 @@ impl TryFrom<ModuleBuilder<'_>> for (ModuleEntry, ModuleStartup) {
345
351
. map ( |( n, v, _) | ( n, v) )
346
352
. collect ( ) ,
347
353
classes : builder. classes ,
354
+ interfaces : builder. interfaces ,
348
355
#[ cfg( feature = "enum" ) ]
349
356
enums : builder. enums ,
350
357
} ;
@@ -400,6 +407,7 @@ mod tests {
400
407
assert ! ( builder. functions. is_empty( ) ) ;
401
408
assert ! ( builder. constants. is_empty( ) ) ;
402
409
assert ! ( builder. classes. is_empty( ) ) ;
410
+ assert ! ( builder. interfaces. is_empty( ) ) ;
403
411
assert ! ( builder. startup_func. is_none( ) ) ;
404
412
assert ! ( builder. shutdown_func. is_none( ) ) ;
405
413
assert ! ( builder. request_startup_func. is_none( ) ) ;
0 commit comments