@@ -284,11 +284,11 @@ impl MavProfile {
284284
285285 fn emit_mav_message_id_from_name ( & self , structs : & [ TokenStream ] ) -> TokenStream {
286286 quote ! {
287- fn message_id_from_name( name: & str ) -> Result <u32 , & ' static str > {
287+ fn message_id_from_name( name: & str ) -> Option <u32 > {
288288 match name {
289- #( #structs:: NAME => Ok ( #structs:: ID ) , ) *
289+ #( #structs:: NAME => Some ( #structs:: ID ) , ) *
290290 _ => {
291- Err ( "Invalid message name." )
291+ None
292292 }
293293 }
294294 }
@@ -301,11 +301,11 @@ impl MavProfile {
301301 structs : & [ TokenStream ] ,
302302 ) -> TokenStream {
303303 quote ! {
304- fn default_message_from_id( id: u32 ) -> Result <Self , & ' static str > {
304+ fn default_message_from_id( id: u32 ) -> Option <Self > {
305305 match id {
306- #( #structs:: ID => Ok ( Self :: #enums( #structs:: default ( ) ) ) , ) *
306+ #( #structs:: ID => Some ( Self :: #enums( #structs:: default ( ) ) ) , ) *
307307 _ => {
308- Err ( "Invalid message id." )
308+ None
309309 }
310310 }
311311 }
@@ -319,10 +319,10 @@ impl MavProfile {
319319 ) -> TokenStream {
320320 quote ! {
321321 #[ cfg( feature = "arbitrary" ) ]
322- fn random_message_from_id<R : rand:: RngCore >( id: u32 , rng: & mut R ) -> Result <Self , & ' static str > {
322+ fn random_message_from_id<R : rand:: RngCore >( id: u32 , rng: & mut R ) -> Option <Self > {
323323 match id {
324- #( #structs:: ID => Ok ( Self :: #enums( #structs:: random( rng) ) ) , ) *
325- _ => Err ( "Invalid message id." ) ,
324+ #( #structs:: ID => Some ( Self :: #enums( #structs:: random( rng) ) ) , ) *
325+ _ => None ,
326326 }
327327 }
328328 }
0 commit comments