Skip to content

Commit

Permalink
Merge pull request #77 from martinling/more-tree-model-improvements
Browse files Browse the repository at this point in the history
More tree model improvements
  • Loading branch information
martinling authored Oct 6, 2023
2 parents fa249ee + 4db6c88 commit 4b46b6c
Show file tree
Hide file tree
Showing 5 changed files with 553 additions and 111 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ rand_xorshift = "0.3.0"
step-decoder = []
record-ui-test = ["serde", "serde_json"]
test-ui-replay = ["serde", "serde_json"]
debug-region-map = []

[[test]]
name = "test_replay"
Expand Down
14 changes: 12 additions & 2 deletions src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,14 @@ pub type EndpointDataEvent = u64;
pub type EndpointByteCount = u64;
pub type DeviceVersion = u32;

#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub enum TrafficItem {
Transfer(TransferId),
Transaction(TransferId, TransactionId),
Packet(TransferId, TransactionId, PacketId),
}

#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub enum DeviceItem {
Device(DeviceId, DeviceVersion),
DeviceDescriptor(DeviceId),
Expand Down Expand Up @@ -1063,6 +1063,16 @@ pub enum CompletionStatus {
Ongoing
}

impl CompletionStatus {
pub fn is_complete(&self) -> bool {
use CompletionStatus::*;
match self {
Complete => true,
Ongoing => false,
}
}
}

pub trait ItemSource<Item> {
fn item(&mut self, parent: Option<&Item>, index: u64)
-> Result<Item, CaptureError>;
Expand Down
2 changes: 1 addition & 1 deletion src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<T> Debug for Id<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>)
-> Result<(), std::fmt::Error>
{
write!(f, "Id({})", self.value)
write!(f, "{}", self.value)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl GenericModel<TrafficItem> for TrafficModel {
{
let tree_opt = self.imp().tree.borrow();
let tree = tree_opt.as_ref().unwrap();
tree.set_expanded(self, node, position, expanded)
tree.set_expanded(self, node, position as u64, expanded)
}

fn update(&self) -> Result<bool, ModelError> {
Expand Down Expand Up @@ -107,7 +107,7 @@ impl GenericModel<DeviceItem> for DeviceModel {
{
let tree_opt = self.imp().tree.borrow();
let tree = tree_opt.as_ref().unwrap();
tree.set_expanded(self, node, position, expanded)
tree.set_expanded(self, node, position as u64, expanded)
}

fn update(&self) -> Result<bool, ModelError> {
Expand Down
Loading

0 comments on commit 4b46b6c

Please sign in to comment.