fn create_struct_field_code(
    cg: &CodeGen,
    namespace: &Ident,
    property: &SchemaGen,
    property_name: &str,
    lowercase_workaround: bool,
) -> Result<StructFieldCode> {
    match &property.ref_key {
        Some(ref_key) => {
            let tp = ref_key.name.to_camel_case_ident()?;
            Ok(StructFieldCode {
                type_name: tp.into(),
                code: None,
            })
        }
        None => {
            if property.is_local_enum() {
                create_enum(Some(namespace), property, property_name, lowercase_workaround)
            } else if property.is_local_struct() {
                let id = property_name.to_camel_case_ident()?;
                let type_name = TypeNameCode::from(vec![namespace.clone(), id]);
                let code = create_struct(cg, property, property_name, None)?;
                Ok(StructFieldCode {
                    type_name,
                    code: Some(TypeCode::Struct(code)),
                })
            } else {
                Ok(StructFieldCode {
                    type_name: type_name_gen(&property.type_name()?)?,
                    code: None,
                })
            }
        }
    }
}
/// Creates the type reference for a struct field from a struct property.
/// Optionally, creates a type for a local schema.
Creates the type reference for a struct field from a struct property.
Optionally, creates a type for a local schema.
Creates the type reference for a struct field from a struct property . Optionally creates a type for a local schema .
fn create_struct_field_code(
    cg: &CodeGen,
    namespace: &Ident,
    property: &SchemaGen,
    property_name: &str,
    lowercase_workaround: bool,
) -> Result<StructFieldCode> {
    match &property.ref_key {
        Some(ref_key) => {
            let tp = ref_key.name.to_camel_case_ident()?;
            Ok(StructFieldCode {
                type_name: tp.into(),
                code: None,
            })
        }
        None => {
            if property.is_local_enum() {
                create_enum(Some(namespace), property, property_name, lowercase_workaround)
            } else if property.is_local_struct() {
                let id = property_name.to_camel_case_ident()?;
                let type_name = TypeNameCode::from(vec![namespace.clone(), id]);
                let code = create_struct(cg, property, property_name, None)?;
                Ok(StructFieldCode {
                    type_name,
                    code: Some(TypeCode::Struct(code)),
                })
            } else {
                Ok(StructFieldCode {
                    type_name: type_name_gen(&property.type_name()?)?,
                    code: None,
                })
            }
        }
    }
}
fn create_struct_field_code ( cg : & CodeGen , namespace : & Ident , property : & SchemaGen , property_name : & str , lowercase_workaround : bool , ) -> Result < StructFieldCode > { match & property . ref_key { Some ( ref_key ) => { let tp = ref_key . name . to_camel_case_ident ( ) ? ; Ok ( StructFieldCode { type_name : tp . into ( ) , code : None , } ) } None => { if property . is_local_enum ( ) { create_enum ( Some ( namespace ) , property , property_name , lowercase_workaround ) } else if property . is_local_struct ( ) { let id = property_name . to_camel_case_ident ( ) ? ; let type_name = TypeNameCode :: from ( vec ! [ namespace clone ( ) id ] ) ; let code = create_struct ( cg , property , property_name , None ) ? ; Ok ( StructFieldCode { type_name , code : Some ( TypeCode :: Struct ( code ) ) , } ) } else { Ok ( StructFieldCode { type_name : type_name_gen ( & property . type_name ( ) ? ) ? , code : None , } ) } } } }
Creates the type reference for a struct field from a struct property.
Creates the type reference for a struct field from a struct property .
cg
&CodeGen
namespace
&Ident
property
&SchemaGen
property_name
&str
lowercase_workaround
bool