<commit_before>// Copyright (C) 2019 O.S. Systems Sofware LTDA
//
// SPDX-License-Identifier: Apache-2.0

use crate::definitions::InstallIfDifferent;
use serde::Deserialize;

#[derive(Deserialize, PartialEq, Debug)]
pub struct Imxkobs {
    pub filename: String,
    pub size: u64,
    pub sha256sum: String,

    pub install_if_different: Option<InstallIfDifferent>,
    #[serde(rename = "1k_padding")]
    #[serde(default)]
    pub padding_1k: bool,
    #[serde(default)]
    pub search_exponent: usize,
    #[serde(default)]
    pub chip_0_device_path: String,
    #[serde(default)]
    pub chip_1_device_path: String,
}

#[test]
fn deserialize() {
    use pretty_assertions::assert_eq;
    use serde_json::json;

    assert_eq!(
        Imxkobs {
            filename: "imxkobs-filename".to_string(),
            size: 1024,
            sha256sum: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
                .to_string(),

            install_if_different: None,
            padding_1k: true,
            search_exponent: 2,
            chip_0_device_path: "/dev/sda1".to_string(),
            chip_1_device_path: "/dev/sda2".to_string(),
        },
        serde_json::from_value::<Imxkobs>(json!({
            "filename": "imxkobs-filename",
            "sha256sum": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
            "size": 1024,
            "1k_padding": true,
            "search_exponent": 2,
            "chip_0_device_path": "/dev/sda1",
            "chip_1_device_path": "/dev/sda2",
        }))
        .unwrap()
    );
}<commit_msg>updatehub-package-schema: Imxkobs chips path as Option<PathBuf><commit_after>// Copyright (C) 2019 O.S. Systems Sofware LTDA
//
// SPDX-License-Identifier: Apache-2.0

use crate::definitions::InstallIfDifferent;
use serde::Deserialize;
use std::path::PathBuf;

#[derive(Deserialize, PartialEq, Debug)]
pub struct Imxkobs {
    pub filename: String,
    pub size: u64,
    pub sha256sum: String,

    pub install_if_different: Option<InstallIfDifferent>,
    #[serde(rename = "1k_padding")]
    #[serde(default)]
    pub padding_1k: bool,
    #[serde(default)]
    pub search_exponent: usize,
    #[serde(default)]
    pub chip_0_device_path: Option<PathBuf>,
    #[serde(default)]
    pub chip_1_device_path: Option<PathBuf>,
}

#[test]
fn deserialize() {
    use pretty_assertions::assert_eq;
    use serde_json::json;

    assert_eq!(
        Imxkobs {
            filename: "imxkobs-filename".to_string(),
            size: 1024,
            sha256sum: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
                .to_string(),

            install_if_different: None,
            padding_1k: true,
            search_exponent: 2,
            chip_0_device_path: Some(PathBuf::from("/dev/sda1")),
            chip_1_device_path: Some(PathBuf::from("/dev/sda2")),
        },
        serde_json::from_value::<Imxkobs>(json!({
            "filename": "imxkobs-filename",
            "sha256sum": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
            "size": 1024,
            "1k_padding": true,
            "search_exponent": 2,
            "chip_0_device_path": "/dev/sda1",
            "chip_1_device_path": "/dev/sda2",
        }))
        .unwrap()
    );
}
{'fraction_non_alphanumeric': 0.12628398791540785, 'fraction_numerical': 0.07673716012084592, 'mean_word_length': 2.737020316027088, 'pattern_counts': {'":': 14, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7544343', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1177, 'n_words': 191}