@@ -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 > ,
@@ -199,7 +200,7 @@ impl ModuleBuilder<'_> {
199
200
///
200
201
/// * Panics if a constant could not be registered.
201
202
pub fn interface < T : RegisteredClass > ( mut self ) -> Self {
202
- self . classes . push ( || {
203
+ self . interfaces . push ( || {
203
204
let mut builder = InterfaceBuilder :: new ( T :: CLASS_NAME ) ;
204
205
for ( method, flags) in T :: method_builders ( ) {
205
206
builder = builder. method ( method, flags) ;
@@ -299,6 +300,7 @@ impl ModuleBuilder<'_> {
299
300
pub struct ModuleStartup {
300
301
constants : Vec < ( String , Box < dyn IntoConst + Send > ) > ,
301
302
classes : Vec < fn ( ) -> ClassBuilder > ,
303
+ interfaces : Vec < fn ( ) -> ClassBuilder > ,
302
304
#[ cfg( feature = "enum" ) ]
303
305
enums : Vec < fn ( ) -> EnumBuilder > ,
304
306
}
@@ -323,6 +325,10 @@ impl ModuleStartup {
323
325
c. register ( ) . expect ( "Failed to build class" ) ;
324
326
} ) ;
325
327
328
+ self . interfaces . into_iter ( ) . map ( |c| c ( ) ) . for_each ( |c| {
329
+ c. register ( ) . expect ( "Failed to build interface" ) ;
330
+ } ) ;
331
+
326
332
#[ cfg( feature = "enum" ) ]
327
333
self . enums
328
334
. into_iter ( )
@@ -365,6 +371,7 @@ impl TryFrom<ModuleBuilder<'_>> for (ModuleEntry, ModuleStartup) {
365
371
. map ( |( n, v, _) | ( n, v) )
366
372
. collect ( ) ,
367
373
classes : builder. classes ,
374
+ interfaces : builder. interfaces ,
368
375
#[ cfg( feature = "enum" ) ]
369
376
enums : builder. enums ,
370
377
} ;
@@ -420,6 +427,7 @@ mod tests {
420
427
assert ! ( builder. functions. is_empty( ) ) ;
421
428
assert ! ( builder. constants. is_empty( ) ) ;
422
429
assert ! ( builder. classes. is_empty( ) ) ;
430
+ assert ! ( builder. interfaces. is_empty( ) ) ;
423
431
assert ! ( builder. startup_func. is_none( ) ) ;
424
432
assert ! ( builder. shutdown_func. is_none( ) ) ;
425
433
assert ! ( builder. request_startup_func. is_none( ) ) ;
0 commit comments