pub fn to_body(&self) -> TokenStream {
        if let Some(field) = self.newtype_raw_body_field() {
            let field_name = field.ident.as_ref().expect("expected field to have an identifier");
            let span = field.span();
            return quote_spanned!(span=> response.#field_name);
        }

        let body = if let Some(field) = self.newtype_body_field() {
            let field_name = field.ident.as_ref().expect("expected field to have an identifier");
            let span = field.span();
            quote_spanned!(span=> response.#field_name)
        } else {
            let fields = self.fields.iter().filter_map(|response_field| {
                if let ResponseField::Body(ref field) = *response_field {
                    let field_name =
                        field.ident.as_ref().expect("expected field to have an identifier");
                    let span = field.span();

                    Some(quote_spanned! {span=>
                        #field_name: response.#field_name
                    })
                } else {
                    None
                }
            });

            quote! {
                ResponseBody { #(#fields),* }
            }
        };

        quote!(ruma_api::exports::serde_json::to_vec(&#body)?)
    }
/// Produces code to initialize the struct that will be used to create the response body.
Produces code to initialize the struct that will be used to create the response body.
Produces code to initialize the struct that will be used to create the response body .
pub fn to_body(&self) -> TokenStream {
        if let Some(field) = self.newtype_raw_body_field() {
            let field_name = field.ident.as_ref().expect("expected field to have an identifier");
            let span = field.span();
            return quote_spanned!(span=> response.#field_name);
        }
        let body = if let Some(field) = self.newtype_body_field() {
            let field_name = field.ident.as_ref().expect("expected field to have an identifier");
            let span = field.span();
            quote_spanned!(span=> response.#field_name)
        } else {
            let fields = self.fields.iter().filter_map(|response_field| {
                if let ResponseField::Body(ref field) = *response_field {
                    let field_name =
                        field.ident.as_ref().expect("expected field to have an identifier");
                    let span = field.span();
                    Some(quote_spanned! {span=>
                        #field_name: response.#field_name
                    })
                } else {
                    None
                }
            });
            quote! {
                ResponseBody { #(#fields),* }
            }
        };
        quote!(ruma_api::exports::serde_json::to_vec(&#body)?)
    }
pub fn to_body ( & self ) -> TokenStream { if let Some ( field ) = self . newtype_raw_body_field ( ) { let field_name = field . ident . as_ref ( ) . expect ( " " ) ; let span = field . span ( ) ; return quote_spanned ! ( span response field_name ) ; } let body = if let Some ( field ) = self . newtype_body_field ( ) { let field_name = field . ident . as_ref ( ) . expect ( " " ) ; let span = field . span ( ) ; quote_spanned ! ( span response field_name ) } else { let fields = self . fields . iter ( ) . filter_map ( | response_field | { if let ResponseField :: Body ( ref field ) = * response_field { let field_name = field . ident . as_ref ( ) . expect ( " " ) ; let span = field . span ( ) ; Some ( quote_spanned ! { span field_name response field_name } ) } else { None } } ) ; quote ! { ResponseBody { ( fields ) } } } ; quote ! ( ruma_api exports serde_json to_vec ( body ) ) }
Produces code to initialize the struct that will be used to create the response body.
Produces code to initialize the struct that will be used to create the response body .
&self
&self