pub(crate) fn enum_variants(&mut self, handle_info: &[HandleMethodInfo]) -> &mut Self {
        for handle in handle_info.iter() {
            let message_type_path = handle.message_type_path;

            let message_ident = message_type_path.path.get_ident().unwrap();

            let default_result_type = Type::Tuple(TypeTuple {
                paren_token: Default::default(),
                elems: Default::default(),
            });
            let result_type = handle
                .message_return_type
                .map(Clone::clone)
                .unwrap_or(default_result_type);

            // construct message enum's new variant from message ident and type path
            let mut unnamed = FieldsUnnamed {
                paren_token: Default::default(),
                unnamed: Default::default(),
            };
            unnamed.unnamed.push(Field {
                attrs: vec![],
                vis: Visibility::Inherited,
                ident: None,
                colon_token: None,
                ty: Type::Path(message_type_path.clone()),
            });
            self.message_enum.variants.push(Variant {
                attrs: vec![],
                ident: message_ident.clone(),
                fields: Fields::Unnamed(unnamed),
                discriminant: None,
            });

            // construct message result enum's new variant from message result type
            // If we are handling a blocking message then we have to transform the result type
            // to Result<message result type, ActixSendError>
            let mut unnamed = FieldsUnnamed {
                paren_token: Default::default(),
                unnamed: Default::default(),
            };
            let ty = if handle.is_async {
                result_type.clone()
            } else {
                let mut tp = TypePath {
                    qself: None,
                    path: Path {
                        leading_colon: None,
                        segments: Default::default(),
                    },
                };

                let mut args = AngleBracketedGenericArguments {
                    colon2_token: None,
                    lt_token: Default::default(),
                    args: Default::default(),
                    gt_token: Default::default(),
                };

                args.args.push(GenericArgument::Type(result_type.clone()));
                args.args
                    .push(GenericArgument::Type(Type::Path(type_path_from_idents(
                        vec![Ident::new("ActixSendError", Span::call_site())],
                    ))));

                tp.path.segments.push(PathSegment {
                    ident: Ident::new("Result", Span::call_site()),
                    arguments: PathArguments::AngleBracketed(args),
                });

                Type::Path(tp)
            };

            unnamed.unnamed.push(Field {
                attrs: vec![],
                vis: Visibility::Inherited,
                ident: None,
                colon_token: None,
                ty,
            });
            self.result_enum.variants.push(Variant {
                attrs: vec![],
                ident: message_ident.clone(),
                fields: Fields::Unnamed(unnamed),
                discriminant: None,
            });
        }

        self
    }
// generate message enum and result enum variants.
generate message enum and result enum variants.
generate message enum and result enum variants .
pub(crate) fn enum_variants(&mut self, handle_info: &[HandleMethodInfo]) -> &mut Self {
        for handle in handle_info.iter() {
            let message_type_path = handle.message_type_path;
            let message_ident = message_type_path.path.get_ident().unwrap();
            let default_result_type = Type::Tuple(TypeTuple {
                paren_token: Default::default(),
                elems: Default::default(),
            });
            let result_type = handle
                .message_return_type
                .map(Clone::clone)
                .unwrap_or(default_result_type);
            // construct message enum's new variant from message ident and type path
            let mut unnamed = FieldsUnnamed {
                paren_token: Default::default(),
                unnamed: Default::default(),
            };
            unnamed.unnamed.push(Field {
                attrs: vec![],
                vis: Visibility::Inherited,
                ident: None,
                colon_token: None,
                ty: Type::Path(message_type_path.clone()),
            });
            self.message_enum.variants.push(Variant {
                attrs: vec![],
                ident: message_ident.clone(),
                fields: Fields::Unnamed(unnamed),
                discriminant: None,
            });
            // construct message result enum's new variant from message result type
            // If we are handling a blocking message then we have to transform the result type
            // to Result<message result type, ActixSendError>
            let mut unnamed = FieldsUnnamed {
                paren_token: Default::default(),
                unnamed: Default::default(),
            };
            let ty = if handle.is_async {
                result_type.clone()
            } else {
                let mut tp = TypePath {
                    qself: None,
                    path: Path {
                        leading_colon: None,
                        segments: Default::default(),
                    },
                };
                let mut args = AngleBracketedGenericArguments {
                    colon2_token: None,
                    lt_token: Default::default(),
                    args: Default::default(),
                    gt_token: Default::default(),
                };
                args.args.push(GenericArgument::Type(result_type.clone()));
                args.args
                    .push(GenericArgument::Type(Type::Path(type_path_from_idents(
                        vec![Ident::new("ActixSendError", Span::call_site())],
                    ))));
                tp.path.segments.push(PathSegment {
                    ident: Ident::new("Result", Span::call_site()),
                    arguments: PathArguments::AngleBracketed(args),
                });
                Type::Path(tp)
            };
            unnamed.unnamed.push(Field {
                attrs: vec![],
                vis: Visibility::Inherited,
                ident: None,
                colon_token: None,
                ty,
            });
            self.result_enum.variants.push(Variant {
                attrs: vec![],
                ident: message_ident.clone(),
                fields: Fields::Unnamed(unnamed),
                discriminant: None,
            });
        }
        self
    }
pub ( crate ) fn enum_variants ( & mut self , handle_info : & [ HandleMethodInfo ] ) -> & mut Self { for handle in handle_info . iter ( ) { let message_type_path = handle . message_type_path ; let message_ident = message_type_path . path . get_ident ( ) . unwrap ( ) ; let default_result_type = Type :: Tuple ( TypeTuple { paren_token : Default :: default ( ) , elems : Default :: default ( ) , } ) ; let result_type = handle . message_return_type . map ( Clone :: clone ) . unwrap_or ( default_result_type ) ; // construct message enum's new variant from message ident and type path let mut unnamed = FieldsUnnamed { paren_token : Default :: default ( ) , unnamed : Default :: default ( ) , } ; unnamed . unnamed . push ( Field { attrs : vec ! [ ] , vis : Visibility :: Inherited , ident : None , colon_token : None , ty : Type :: Path ( message_type_path . clone ( ) ) , } ) ; self . message_enum . variants . push ( Variant { attrs : vec ! [ ] , ident : message_ident . clone ( ) , fields : Fields :: Unnamed ( unnamed ) , discriminant : None , } ) ; // construct message result enum's new variant from message result type // If we are handling a blocking message then we have to transform the result type // to Result<message result type, ActixSendError> let mut unnamed = FieldsUnnamed { paren_token : Default :: default ( ) , unnamed : Default :: default ( ) , } ; let ty = if handle . is_async { result_type . clone ( ) } else { let mut tp = TypePath { qself : None , path : Path { leading_colon : None , segments : Default :: default ( ) , } , } ; let mut args = AngleBracketedGenericArguments { colon2_token : None , lt_token : Default :: default ( ) , args : Default :: default ( ) , gt_token : Default :: default ( ) , } ; args . args . push ( GenericArgument :: Type ( result_type . clone ( ) ) ) ; args . args . push ( GenericArgument :: Type ( Type :: Path ( type_path_from_idents ( vec ! [ Ident new ( " " Span call_site ( ) ) ] , ) ) ) ) ; tp . path . segments . push ( PathSegment { ident : Ident :: new ( " " , Span :: call_site ( ) ) , arguments : PathArguments :: AngleBracketed ( args ) , } ) ; Type :: Path ( tp ) } ; unnamed . unnamed . push ( Field { attrs : vec ! [ ] , vis : Visibility :: Inherited , ident : None , colon_token : None , ty , } ) ; self . result_enum . variants . push ( Variant { attrs : vec ! [ ] , ident : message_ident . clone ( ) , fields : Fields :: Unnamed ( unnamed ) , discriminant : None , } ) ; } self }
generate message enum and result enum variants.
generate message enum and result enum variants .
&mut self
handle_info
&[HandleMethodInfo]