From 38cbd5bc4639e082483ae90fb56cc57c7f853465 Mon Sep 17 00:00:00 2001 From: Cyril Marpaud Date: Fri, 16 Feb 2024 19:24:05 +0100 Subject: [PATCH] refactor: remove the types module --- src/{types => }/chip.rs | 2 +- src/{types => }/chip/family.rs | 0 src/{types => }/chip/family/mem_region.rs | 18 +++++++++--------- src/{types => }/chip/target.rs | 0 src/{types => }/error.rs | 0 src/init.rs | 4 ++-- src/main.rs | 6 ++++-- src/{types => }/parser.rs | 4 +++- src/{types => parser}/init_args.rs | 0 .../init_args/panic_handler.rs | 0 src/{types => parser}/init_args/soft_device.rs | 0 src/types.rs | 4 ---- 12 files changed, 19 insertions(+), 19 deletions(-) rename src/{types => }/chip.rs (98%) rename src/{types => }/chip/family.rs (100%) rename src/{types => }/chip/family/mem_region.rs (63%) rename src/{types => }/chip/target.rs (100%) rename src/{types => }/error.rs (100%) rename src/{types => }/parser.rs (92%) rename src/{types => parser}/init_args.rs (100%) rename src/{types => parser}/init_args/panic_handler.rs (100%) rename src/{types => parser}/init_args/soft_device.rs (100%) delete mode 100644 src/types.rs diff --git a/src/types/chip.rs b/src/chip.rs similarity index 98% rename from src/types/chip.rs rename to src/chip.rs index 0fe734a..a2fc418 100644 --- a/src/types/chip.rs +++ b/src/chip.rs @@ -1,7 +1,7 @@ pub mod family; pub mod target; -use crate::types::error::{Error, InvalidChip}; +use crate::error::{Error, InvalidChip}; use std::str::FromStr; pub(crate) struct Chip { diff --git a/src/types/chip/family.rs b/src/chip/family.rs similarity index 100% rename from src/types/chip/family.rs rename to src/chip/family.rs diff --git a/src/types/chip/family/mem_region.rs b/src/chip/family/mem_region.rs similarity index 63% rename from src/types/chip/family/mem_region.rs rename to src/chip/family/mem_region.rs index 3715d31..fe61cc9 100644 --- a/src/types/chip/family/mem_region.rs +++ b/src/chip/family/mem_region.rs @@ -1,5 +1,5 @@ #[derive(Clone, Debug)] -pub(crate) struct MemRegion { +pub struct MemRegion { pub flash_origin: usize, pub flash_length: usize, @@ -8,38 +8,38 @@ pub(crate) struct MemRegion { } impl MemRegion { - pub(crate) const NRF52805: Self = Self { + pub const NRF52805: Self = Self { flash_origin: 0, flash_length: 192, ram_origin: 0x2 << 28, ram_length: 24, }; - pub(crate) const NRF52810: Self = Self::NRF52805; - pub(crate) const NRF52811: Self = Self::NRF52805; + pub const NRF52810: Self = Self::NRF52805; + pub const NRF52811: Self = Self::NRF52805; - pub(crate) const NRF52820: Self = Self { + pub const NRF52820: Self = Self { flash_origin: 0, flash_length: 256, ram_origin: 0x2 << 28, ram_length: 32, }; - pub(crate) const NRF52832_XXAA: Self = Self { + pub const NRF52832_XXAA: Self = Self { flash_origin: 0, flash_length: 512, ram_origin: 0x2 << 28, ram_length: 64, }; - pub(crate) const NRF52832_XXAB: Self = Self::NRF52820; + pub const NRF52832_XXAB: Self = Self::NRF52820; - pub(crate) const NRF52833: Self = Self { + pub const NRF52833: Self = Self { flash_origin: 0, flash_length: 512, ram_origin: 0x2 << 28, ram_length: 128, }; - pub(crate) const NRF52840: Self = Self { + pub const NRF52840: Self = Self { flash_origin: 0, flash_length: 1024, ram_origin: 0x2 << 28, diff --git a/src/types/chip/target.rs b/src/chip/target.rs similarity index 100% rename from src/types/chip/target.rs rename to src/chip/target.rs diff --git a/src/types/error.rs b/src/error.rs similarity index 100% rename from src/types/error.rs rename to src/error.rs diff --git a/src/init.rs b/src/init.rs index 6aa260f..3f41c1b 100644 --- a/src/init.rs +++ b/src/init.rs @@ -1,11 +1,11 @@ -use crate::types::{ +use crate::{ chip::{ family::{mem_region::MemRegion, Family}, target::Target, Chip, }, error::{Error, InvalidChip}, - init_args::{panic_handler::PanicHandler, soft_device::Softdevice, InitArgs}, + parser::init_args::{panic_handler::PanicHandler, soft_device::Softdevice, InitArgs}, }; use indicatif::ProgressBar; use inflector::cases::snakecase::to_snake_case; diff --git a/src/main.rs b/src/main.rs index 15838d2..f6137d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,11 @@ +pub mod chip; +pub mod error; mod init; -mod types; +pub mod parser; use clap::Parser; use init::Init; -use types::parser::{Cargo, EmbassyCommand}; +use parser::{Cargo, EmbassyCommand}; fn main() { let Cargo::Embassy(embassy) = Cargo::parse(); diff --git a/src/types/parser.rs b/src/parser.rs similarity index 92% rename from src/types/parser.rs rename to src/parser.rs index a2aec50..567b15f 100644 --- a/src/types/parser.rs +++ b/src/parser.rs @@ -1,5 +1,7 @@ -use crate::types::init_args::InitArgs; +pub mod init_args; + use clap::{Args, Parser, Subcommand}; +use init_args::InitArgs; #[derive(Parser)] #[command(name = "cargo")] diff --git a/src/types/init_args.rs b/src/parser/init_args.rs similarity index 100% rename from src/types/init_args.rs rename to src/parser/init_args.rs diff --git a/src/types/init_args/panic_handler.rs b/src/parser/init_args/panic_handler.rs similarity index 100% rename from src/types/init_args/panic_handler.rs rename to src/parser/init_args/panic_handler.rs diff --git a/src/types/init_args/soft_device.rs b/src/parser/init_args/soft_device.rs similarity index 100% rename from src/types/init_args/soft_device.rs rename to src/parser/init_args/soft_device.rs diff --git a/src/types.rs b/src/types.rs deleted file mode 100644 index 83e0b3d..0000000 --- a/src/types.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod chip; -pub mod error; -pub mod init_args; -pub mod parser;