diff --git a/src/capture.rs b/src/capture.rs index a99eef0f..bce2319d 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -9,7 +9,6 @@ use std::sync::atomic::Ordering::{Acquire, Release}; use std::sync::Arc; use std::mem::size_of; -use crate::id::{Id, HasLength}; use crate::database::{ CompactReader, CompactWriter, @@ -19,10 +18,15 @@ use crate::database::{ data_stream, data_stream_with_block_size, }; -use crate::rcu::SingleWriterRcu; -use crate::vec_map::{Key, VecMap}; use crate::usb::{self, prelude::*}; -use crate::util::{Bytes, fmt_count, fmt_size}; +use crate::util::{ + id::{Id, HasLength}, + rcu::SingleWriterRcu, + vec_map::{Key, VecMap}, + Bytes, + fmt_count, + fmt_size, +}; use anyhow::{Context, Error, bail}; use arc_swap::{ArcSwap, ArcSwapOption}; diff --git a/src/database/compact_index.rs b/src/database/compact_index.rs index 129dbeb9..03efd4d8 100644 --- a/src/database/compact_index.rs +++ b/src/database/compact_index.rs @@ -17,8 +17,7 @@ use crate::database::{ data_stream::{data_stream, DataReader, DataWriter, DataIterator}, index_stream::{index_stream, IndexReader, IndexWriter, IndexIterator}, }; -use crate::id::Id; -use crate::util::{fmt_count, fmt_size}; +use crate::util::{id::Id, fmt_count, fmt_size}; type Offset = Id; type SegmentId = Id; diff --git a/src/database/data_stream.rs b/src/database/data_stream.rs index 4539b839..0d990358 100644 --- a/src/database/data_stream.rs +++ b/src/database/data_stream.rs @@ -9,7 +9,7 @@ use std::ops::{Deref, Range}; use anyhow::Error; use bytemuck::{bytes_of, cast_slice, from_bytes, Pod}; -use crate::id::Id; +use crate::util::id::Id; use crate::database::stream::{ stream, StreamReader, diff --git a/src/database/index_stream.rs b/src/database/index_stream.rs index bfc3c27f..f7eab6de 100644 --- a/src/database/index_stream.rs +++ b/src/database/index_stream.rs @@ -17,8 +17,7 @@ use crate::database::{ DataIterator }, }; -use crate::id::Id; -use crate::util::{fmt_count, fmt_size}; +use crate::util::{id::Id, fmt_count, fmt_size}; /// Unique handle for append-only write access to an index. pub struct IndexWriter { diff --git a/src/decoder.rs b/src/decoder.rs index 923f4dd6..54832646 100644 --- a/src/decoder.rs +++ b/src/decoder.rs @@ -8,9 +8,11 @@ use std::sync::Arc; use anyhow::{Context, Error, bail}; use crate::capture::prelude::*; -use crate::rcu::SingleWriterRcu; use crate::usb::{self, prelude::*, validate_packet}; -use crate::vec_map::VecMap; +use crate::util::{ + rcu::SingleWriterRcu, + vec_map::VecMap, +}; struct EndpointData { device_id: DeviceId, diff --git a/src/fuzzer.rs b/src/fuzzer.rs index e4dcf539..b30e3132 100644 --- a/src/fuzzer.rs +++ b/src/fuzzer.rs @@ -11,12 +11,9 @@ use libfuzzer_sys::{arbitrary::{Arbitrary, Unstructured}, fuzz_target}; mod capture; mod database; mod decoder; -mod id; mod pcap; -mod rcu; mod usb; mod util; -mod vec_map; use capture::create_capture; use decoder::Decoder; diff --git a/src/item.rs b/src/item.rs index f3a706f4..265a9aff 100644 --- a/src/item.rs +++ b/src/item.rs @@ -20,9 +20,11 @@ use crate::capture::{ PacketId, INVALID_EP_ID, }; -use crate::id::HasLength; use crate::usb::{self, prelude::*, validate_packet}; -use crate::util::{Bytes, fmt_count, fmt_size, titlecase}; +use crate::util::{ + id::HasLength, + Bytes, fmt_count, fmt_size, titlecase +}; pub trait ItemSource { /// Fetch an item from the source by index, relative to either the root diff --git a/src/main.rs b/src/main.rs index 5273d40f..0ec7caf7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,15 +24,12 @@ mod backend; mod capture; mod database; mod decoder; -mod id; mod item; mod pcap; -mod rcu; mod test_cynthion; mod ui; mod usb; mod util; -mod vec_map; mod version; use gtk::prelude::*; diff --git a/src/usb.rs b/src/usb.rs index c72156dd..e7d973e8 100644 --- a/src/usb.rs +++ b/src/usb.rs @@ -22,8 +22,10 @@ use num_enum::{IntoPrimitive, FromPrimitive}; use derive_more::{From, Into, Display}; use usb_ids::FromId; -use crate::util::titlecase; -use crate::vec_map::VecMap; +use crate::util::{ + vec_map::VecMap, + titlecase +}; fn crc16(bytes: &[u8]) -> u16 { const CRC16: Crc = Crc::::new(&CRC_16_USB); diff --git a/src/id.rs b/src/util/id.rs similarity index 100% rename from src/id.rs rename to src/util/id.rs diff --git a/src/util.rs b/src/util/mod.rs similarity index 98% rename from src/util.rs rename to src/util/mod.rs index 23d75da9..7890e645 100644 --- a/src/util.rs +++ b/src/util/mod.rs @@ -5,6 +5,10 @@ use num_format::{Locale, ToFormattedString}; use humansize::{SizeFormatter, BINARY}; use itertools::Itertools; +pub mod id; +pub mod vec_map; +pub mod rcu; + pub fn fmt_count(count: u64) -> String { count.to_formatted_string(&Locale::en) } diff --git a/src/rcu.rs b/src/util/rcu.rs similarity index 100% rename from src/rcu.rs rename to src/util/rcu.rs diff --git a/src/vec_map.rs b/src/util/vec_map.rs similarity index 99% rename from src/vec_map.rs rename to src/util/vec_map.rs index caba73b9..e414c261 100644 --- a/src/vec_map.rs +++ b/src/util/vec_map.rs @@ -5,7 +5,7 @@ use std::ops::{Index, IndexMut}; use std::marker::PhantomData; use std::slice::Iter; -use crate::id::Id; +use crate::util::id::Id; pub trait Key { fn id(self) -> usize;