Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom: missing field id #192

Open
lebe-dev opened this issue Dec 15, 2022 · 0 comments
Open

custom: missing field id #192

lebe-dev opened this issue Dec 15, 2022 · 0 comments

Comments

@lebe-dev
Copy link

lebe-dev commented Dec 15, 2022

Help me to solve puzzle. I have xml from sysPass:

<?xml version="1.0" encoding="UTF-8"?>
<Root>
    <Meta>
        <Generator>sysPass</Generator>
        <Version>3211.22070201</Version>
        <Time>1669620743</Time>
        <User id="1">admin</User>
        <Group id="1">Admins</Group>
        <Hash sign="9e971d659816a7dd325e4c75f97c9853605be53db81b514f90103757a61af51b">
            b5141af49246795c42e74012c19dab36974708be
        </Hash>
    </Meta>
    <Categories>
        <Category id="1">
            <name>APP</name>
            <description></description>
        </Category>
    </Categories>
    <Clients>
        <Client id="1">
            <name>BirchStore</name>
            <description></description>
        </Client>
    </Clients>
    <Tags>
        <Tag id="1">
            <name>Shop</name>
        </Tag>
        <Tag id="2">
            <name>SSO</name>
        </Tag>
    </Tags>
    <Accounts>
        <Account id="1">
            <name>Ivan Petrov</name>
            <clientId>1</clientId>
            <categoryId>1</categoryId>
            <login>i.petrov</login>
            <url>https://app.internal.company.ru:5555/app/</url>
            <notes>
                [email protected]
            </notes>
            <pass>v23t8nv2u394tyd</pass>
            <key></key>
            <tags>
                <tag id="1"/>
                <tag id="2"/>
            </tags>
        </Account>
        <Account id="2">
            <name>Abramova Nina</name>
            <clientId>1</clientId>
            <categoryId>1</categoryId>
            <login>n.abramova</login>
            <url>https://stage.internal.company.ru</url>
            <notes>
                [email protected]
            </notes>
            <pass>v35n8t39485tg</pass>
            <key></key>
            <tags>
                <tag id="1"/>
                <tag id="2"/>
            </tags>
        </Account>
    </Accounts>
</Root>

I don't need all tags, but i need just category ids:

#[derive(Deserialize,PartialEq,Debug)]
pub struct XmlConfig {
    #[serde(rename = "Categories")]
    pub categories: Vec<Category>
}

#[derive(Deserialize,PartialEq,Debug)]
pub struct Category {
    pub id: String,
}

Function:

pub fn get_xml_config_from_file(file_path: &Path) -> Result<XmlConfig, Error> {
    info!("load xml configuration from file '{}'", file_path.display());
    let xml = fs::read_to_string(file_path)
                            .context("couldn't read xml file")?;
    let config: XmlConfig = from_str(&xml)
                                .context("couldn't deserialize xml from file")?;

    debug!("---[xml config]---");
    debug!("{:?}", config);
    debug!("---[/xml config]---");
    Ok(config)
}

And i got error:

[custom](custom: missing field `id`) 

Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant