Skip to content

Commit

Permalink
Use unpack_event
Browse files Browse the repository at this point in the history
Summary:
This just cuts out some boilerplate (I think it'd be even nicer of the
enum variants were normal structs rather than tuple structs, but maybe another time).

Reviewed By: krallin

Differential Revision: D43941395

fbshipit-source-id: 65f1af3fad70d08d42b5e1299b4d35f39fcbecb8
  • Loading branch information
cjhopman authored and facebook-github-bot committed Apr 6, 2023
1 parent 89e5f04 commit ae5a357
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app/buck2_client_ctx/src/subscribers/re_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use std::time::Duration;
use anyhow::Context;
use async_trait::async_trait;
use buck2_core::fs::paths::file_name::FileNameBuf;
use buck2_event_observer::unpack_event::unpack_event;
use buck2_event_observer::unpack_event::UnpackedBuckEvent;
use buck2_events::BuckEvent;
use futures::Future;
use futures::FutureExt;
Expand Down Expand Up @@ -63,14 +65,13 @@ impl EventSubscriber for ReLog {

async fn handle_events(&mut self, events: &[Arc<BuckEvent>]) -> anyhow::Result<()> {
for event in events {
match event.data() {
buck2_data::buck_event::Data::Instant(ref instant) => {
match instant.data.as_ref().context("Missing `data`")? {
buck2_data::instant_event::Data::ReSession(session) => {
self.re_session_id = Some(session.session_id.clone());
}
_ => {}
}
match unpack_event(event)? {
UnpackedBuckEvent::Instant(
_,
_,
buck2_data::instant_event::Data::ReSession(session),
) => {
self.re_session_id = Some(session.session_id.clone());
}
_ => {}
}
Expand Down

0 comments on commit ae5a357

Please sign in to comment.