Open Bug 1755655 Opened 3 years ago

Add read_sync_header() helper

Categories

(Testing :: Mozbase Rust, enhancement, P3)

Default
enhancement

Tracking

(Not tracked)

People

(Reporter: whimboo, Unassigned)

References

(Blocks 1 open bug)

Details

As suggested by James in https://phabricator.services.mozilla.com/D131011#inline-760270 it would be good to have a helper that reads the sync header in the following way:

Not necessary for this change, but a helper like read_sync_header(stream: &mut TcpStream) -> IOResult<(SyncCommand, u32)> might be useful, since then you could just write

let (command, length) = read_sync_header(&mut stream)?;
match command {
  SyncCommand::Data => {
    stream.read_exact(&mut buf[0..length])?;
    […]
  },
  […]
}
You need to log in before you can comment on or make changes to this bug.