You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: extract.rs
    path of file: ./repos/salvo/crates/macros/src
    
    the code of the file until where you have to start completion: use proc_macro2::{Ident, Span, TokenStream};
use quote::quote;
use syn::parse::Parse;
use syn::parse::ParseStream;
use syn::punctuated::Punctuated;
use syn::token::Comma;
use syn::{DeriveInput, Error, Expr, ExprLit, Field, Generics, Lit, Meta, MetaNameValue, Token, Type};

use crate::{
    attribute, omit_type_path_lifetimes, salvo_crate,
    serde_util::{self, RenameRule, SerdeValue},
};

struct FieldInfo {
    ident: Option<Ident>,
    ty: Type,
    sources: Vec<SourceInfo>,
    aliases: Vec<String>,
    rename: Option<String>,
    serde_rename: Option<String>,
    flatten: bool,
}
impl TryFrom<&Field> for FieldInfo {
    type Error = Error;

    fn try_from(field: &Field) -> Result<Self, Self::Error> {
        let ident = field.ident.clone();
        let attrs = field.attrs.clone();
        let mut sources: Vec<SourceInfo> = Vec::with_capacity(field.attrs.len());
        let mut aliases = Vec::with_capacity(field.attrs.len());
        let mut rename = None;
        let mut flatten = None;
        for attr in attrs {
            if attr.path().is_ident("salvo") {
                if let Ok(Some(metas)) = attribute::find_nested_list(&attr, "extract") {
                    let info: ExtractField
    
pub(crate) fn generate(args: DeriveInput) -> Result<TokenStream, Error> {
    let mut args: ExtractibleArgs = ExtractibleArgs::from_derive_input(&args)?;
    let salvo = salvo_crate();
    let (_, ty_generics, where_clause) = args.generics.split_for_impl();

    let name = &args.ident;
    let mut default_sources = Vec::new();
    let mut fields = Vec::new();

    for source in &args.default_sources {
        let source = metadata_source(&salvo, source);
        default_sources.push(quote! {
            metadata = metadata.add_default_source(#source);
        });
    }
    fn quote_rename_rule(salvo: &Ident, rename_all: &RenameRule) -> TokenStream {
        let rename_all = match rename_all {
            RenameRule::LowerCase => "LowerCase",
            RenameRule::UpperCase => "UpperCase",
            RenameRule::PascalCase => "PascalCase",
            RenameRule::CamelCase => "CamelCase",
            RenameRule::SnakeCase => "SnakeCase",
            RenameRule::ScreamingSnakeCase => "ScreamingSnakeCase",
            RenameRule::KebabCase => "KebabCase",
            RenameRule::ScreamingKebabCase => "ScreamingKebabCase",
        };
        let rule = Ident::new(rename_all, Span::call_site());
        quote! {
            #salvo::extract::RenameRule::#rule
        }
    }
    let rename_all = if let Some(rename_all) = &args.rename_all {
        let rule = quote_rename_rule(&salvo, rename_all);
        Some(quote! {
            metadata = metadata.rename_all(#rule);
        })
    } else {
        None
    };
    let serde_rename_all = if let Some(serde_rename_all) = &args.serde_rename_all {
        let rule = quote_rename_rule(&salvo, serde_rename_all);
        Some(quote! {
            metadata = metadata.serde_rename_all(#rule);
        })
    } else {
        None
    };

    for field in &mut args.fields {
        let field_ident = field
            .ident
            .as_ref()
            .ok_or_else(|| Error::new_spanned(name, "All fields must be named."))?
            .to_string();
        let mut nested_metadata = None;
        let mut sources = Vec::with_capacity(field.sources.len());
        if field.flatten {
            if let Type::Path(ty) = &field.ty {
                let ty = omit_type_path_lifetimes(ty);
                nested_metadata = Some(quote! {
                    field = field.metadata(<#ty as #salvo::extract::Extractible>::metadata());
                    field = field.flatten(true);
                });
            } else {
                return Err(Error::new_spanned(name, "Invalid type for request source."));
            }
        } else {
            for source in &field.sources {
                let source = metadata_source(&salvo, source);
                sources.push(quote! {
                    field = field.add_source(#source);
                });
            }
        }
        if nested_metadata.is_some() && field.sources.len() > 1 {
            return Err(Error::new_spanned(name, "Only one source can be from request."));
        }
        let aliases = field.aliases.iter().map(|alias| {
            quote! {
                field = field.add_alias(#alias);
            }
        });
        let rename = field.rename.as_ref().map(|rename| {
            quote! {
                field = field.rename(#rename);
            }
        });
        let serde_rename = field.serde_rename.as_ref().map(|serde_rename| {
            quote! {
                field = field.serde_rename(#serde_rename);
            }
        });
        fields.push(quote! {
            let mut field = #salvo::extract::metadata::Field::new(#field_ident);
            #nested_metadata
            #(#sources)*
            #(#aliases)*
            #rename
            #serde_rename
            metadata = metadata.add_field(field);
        });
    }

    let mt = name.to_string();
    let metadata = quote! {
        fn metadata() ->  &'static #salvo::extract::Metadata {
            static METADATA: #salvo::__private::once_cell::sync::OnceCell<#salvo::extract::Metadata> = #salvo::__private::once_cell::sync::OnceCell::new();
            METADATA.get_or_init(|| {
                let mut metadata = #salvo::extract::Metadata::new(#mt);
                #(
                    #default_sources
                )*
                #rename_all
                #serde_rename_all
                #(
                    #fields
                )*
                metadata
            })
        }
    };
    let life_param = args.generics.lifetimes().next();
    let code = if let Some(life_param) = life_param {
        let ex_life_def =
            syn::parse_str(&format!("'__macro_gen_ex:{}", life_param.lifetime)).expect("Invalid lifetime.");
        let mut generics = args.generics.clone();
        generics.params.insert(0, ex_life_def);
        let impl_generics_de = generics.split_for_impl().0;
        quote! {
            impl #impl_generics_de #salvo::extract::Extractible<'__macro_gen_ex> for #name #ty_generics #where_clause {
                #metadata

                #[allow(refining_impl_trait)]
                async fn extract(req: &'__macro_gen_ex mut #salvo::http::Request) -> Result<Self, #salvo::http::ParseError>
                where
                    Self: Sized {
                    #salvo::serde::from_request(req, Self::metadata()).await
                }
            }
        }
    } else {
        let ex_life_def = syn::parse_str("'__macro_gen_ex").expect("Invalid lifetime.");
        let mut generics = args.generics.clone();
        generics.params.insert(0, ex_life_def);
        let impl_generics_de = generics.split_for_impl().0;
        quote! {
            impl #impl_generics_de #salvo::extract::Extractible<'__macro_gen_ex> for #name #ty_generics #where_clause {
                #metadata

                #[allow(refining_impl_trait)]
                async fn extract(req: &'__macro_gen_ex mut #salvo::http::Request) -> Result<Self, #salvo::http::ParseError>
                where
                    Self: Sized {
                    #salvo::serde::from_request(req, Self::metadata()).await
                }
            }
        }
    };
    Ok(code)
}