@@ -380,6 +380,7 @@ pub fn gen_idl_type(
380380 syn:: Type :: Path ( path) if the_only_segment_is ( path, "bool" ) => {
381381 Ok ( ( quote ! { #idl:: IdlType :: Bool } , vec ! [ ] ) )
382382 }
383+ // Integer types
383384 syn:: Type :: Path ( path) if the_only_segment_is ( path, "u8" ) => {
384385 Ok ( ( quote ! { #idl:: IdlType :: U8 } , vec ! [ ] ) )
385386 }
@@ -416,6 +417,56 @@ pub fn gen_idl_type(
416417 syn:: Type :: Path ( path) if the_only_segment_is ( path, "i128" ) => {
417418 Ok ( ( quote ! { #idl:: IdlType :: I128 } , vec ! [ ] ) )
418419 }
420+ // Non-zero integer types
421+ syn:: Type :: Path ( path) if the_only_segment_is ( path, "NonZeroU8" ) => Ok ( (
422+ quote ! { #idl:: IdlType :: NonZero ( Box :: new( #idl:: IdlType :: U8 ) ) } ,
423+ vec ! [ ] ,
424+ ) ) ,
425+ syn:: Type :: Path ( path) if the_only_segment_is ( path, "NonZeroI8" ) => Ok ( (
426+ quote ! { #idl:: IdlType :: NonZero ( Box :: new( #idl:: IdlType :: I8 ) ) } ,
427+ vec ! [ ] ,
428+ ) ) ,
429+ syn:: Type :: Path ( path) if the_only_segment_is ( path, "NonZeroU16" ) => Ok ( (
430+ quote ! { #idl:: IdlType :: NonZero ( Box :: new( #idl:: IdlType :: U16 ) ) } ,
431+ vec ! [ ] ,
432+ ) ) ,
433+ syn:: Type :: Path ( path) if the_only_segment_is ( path, "NonZeroI16" ) => Ok ( (
434+ quote ! { #idl:: IdlType :: NonZero ( Box :: new( #idl:: IdlType :: I16 ) ) } ,
435+ vec ! [ ] ,
436+ ) ) ,
437+ syn:: Type :: Path ( path) if the_only_segment_is ( path, "NonZeroU32" ) => Ok ( (
438+ quote ! { #idl:: IdlType :: NonZero ( Box :: new( #idl:: IdlType :: U32 ) ) } ,
439+ vec ! [ ] ,
440+ ) ) ,
441+ syn:: Type :: Path ( path) if the_only_segment_is ( path, "NonZeroI32" ) => Ok ( (
442+ quote ! { #idl:: IdlType :: NonZero ( Box :: new( #idl:: IdlType :: I32 ) ) } ,
443+ vec ! [ ] ,
444+ ) ) ,
445+ syn:: Type :: Path ( path) if the_only_segment_is ( path, "NonZeroU64" ) => Ok ( (
446+ quote ! { #idl:: IdlType :: NonZero ( Box :: new( #idl:: IdlType :: U64 ) ) } ,
447+ vec ! [ ] ,
448+ ) ) ,
449+ syn:: Type :: Path ( path) if the_only_segment_is ( path, "NonZeroI64" ) => Ok ( (
450+ quote ! { #idl:: IdlType :: NonZero ( Box :: new( #idl:: IdlType :: I64 ) ) } ,
451+ vec ! [ ] ,
452+ ) ) ,
453+ syn:: Type :: Path ( path) if the_only_segment_is ( path, "NonZeroU128" ) => Ok ( (
454+ quote ! { #idl:: IdlType :: NonZero ( Box :: new( #idl:: IdlType :: U128 ) ) } ,
455+ vec ! [ ] ,
456+ ) ) ,
457+ syn:: Type :: Path ( path) if the_only_segment_is ( path, "NonZeroI128" ) => Ok ( (
458+ quote ! { #idl:: IdlType :: NonZero ( Box :: new( #idl:: IdlType :: I128 ) ) } ,
459+ vec ! [ ] ,
460+ ) ) ,
461+ syn:: Type :: Path ( path) if the_only_segment_is ( path, "NonZero" ) => {
462+ let segment = get_first_segment ( path) ;
463+ let arg = get_angle_bracketed_type_args ( segment)
464+ . into_iter ( )
465+ . next ( )
466+ . unwrap ( ) ;
467+ let ( inner, defined) = gen_idl_type ( arg, generic_params) ?;
468+ Ok ( ( quote ! { #idl:: IdlType :: NonZero ( Box :: new( #inner) ) } , defined) )
469+ }
419470 syn:: Type :: Path ( path)
420471 if the_only_segment_is ( path, "String" ) || the_only_segment_is ( path, "str" ) =>
421472 {
0 commit comments