Skip to content

Conversation

@adrian-kong
Copy link
Contributor

@adrian-kong adrian-kong commented Nov 25, 2022

Intended for with_rover_time, important to not do redundant to_sbp calls after, so this just assumes that we want

(Frame, Time)
since we cant easily convert from sbp -> frame,

or maybe alternatively we can retain frame and sbp.

This is so that we can do
Framer::new(...).with_rover_time() for (Frame, Time) tuple
instead of only
sbp::iter_messages(...).with_rover_time() for (Sbp, Time) tuple

@adrian-kong adrian-kong changed the title has time for frames Implement HasTime for Frames Nov 25, 2022
@adrian-kong adrian-kong changed the title Implement HasTime for Frames Implement HasTime for Frames [DEVINFRA-516] Nov 29, 2022
@adrian-kong adrian-kong requested review from a team and joelynch November 29, 2022 00:33
Copy link
Contributor

@joelynch joelynch left a comment

Choose a reason for hiding this comment

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

Seems good

@notoriaga
Copy link
Contributor

One thing that bothers me a bit about this is that if you have

for (frame, time) in Framer::new(...).with_rover_time() {
    ....
    let msg = frame.to_sbp();
    ...
}

you end up converting the frame twice.

or maybe alternatively we can retain frame and sbp.

would avoid that, but not sure what a clean way to do that is. maybe we could add a method to Framer that returns both

impl Framer {
    pub fn with_messages(self) -> impl Iterator<Item=(Frame, Result<Sbp>)> {
        self.map(|f| (f, f.to_sbp()))
    }
}

and then you can impl HasTime for (Frame, Result<Sbp>) as well. Either way I think it's fine as is

@silverjam
Copy link
Contributor

One thing that bothers me a bit about this is that if you have

for (frame, time) in Framer::new(...).with_rover_time() {
    ....
    let msg = frame.to_sbp();
    ...
}

you end up converting the frame twice.

or maybe alternatively we can retain frame and sbp.

would avoid that, but not sure what a clean way to do that is. maybe we could add a method to Framer that returns both

impl Framer {
    pub fn with_messages(self) -> impl Iterator<Item=(Frame, Result<Sbp>)> {
        self.map(|f| (f, f.to_sbp()))
    }
}

and then you can impl HasTime for (Frame, Result<Sbp>) as well. Either way I think it's fine as is

Let's track with an issue and revisit @adrian-kong

@adrian-kong adrian-kong merged commit aecb783 into master Dec 1, 2022
@adrian-kong adrian-kong deleted the adrian/hastime_frame branch December 1, 2022 00:04
@adrian-kong
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants