Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions humility-probes-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,16 @@ pub fn attach_for_flashing(
) -> Result<Box<dyn Core>> {
attach_to_chip(probe, Some(chip), speed_khz)
}

/// Extension trait to make it easier for libraries to attach
/// to chips. It is encourageed to extend this trait as
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// to chips. It is encourageed to extend this trait as
/// to chips. It is encouraged to extend this trait as

/// needed to make developer's lives easier.
pub trait HubrisAttach {
fn attach_to_chip(&self, probe: &str) -> Result<Box<dyn Core>>;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe document what this is supposed to do and when this should/shouldn't fail?

}

impl HubrisAttach for humility::hubris::HubrisArchive {
fn attach_to_chip(&self, probe: &str) -> Result<Box<dyn Core>> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a check, do we want this to be Box<dyn Core> instead of being an assoc type? (if we're already using it as dyn everywhere in existing code, the answer is probably "yes")

Perf wise it probably doesn't matter, but just checking because sometimes dyn Trait is "a land of contrasts", as Eliza would say.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attach_to_chip(probe, self.chip().as_deref(), None)
}
}
Loading