Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions src/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::io;
use std::io::Read;
use std::io::Result as IOResult;
use std::io::{Error as IOError, ErrorKind};
use std::u32;

/// Magic number found at the start of replay files
pub const FILE_MAGIC: &[u8] = b"YLPR";
Expand Down Expand Up @@ -170,7 +169,7 @@ fn read_str<R: Read>(mut reader: R, length: usize) -> IOResult<String> {
.position(|&b| b == 0)
.expect("Given string does not terminate within given length");

Ok(String::from_utf8((&raw_string_bytes[..nul]).to_vec()).unwrap())
Ok(String::from_utf8((raw_string_bytes[..nul]).to_vec()).unwrap())
}

impl<R: Read> Replay<R> {
Expand Down
13 changes: 6 additions & 7 deletions src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,7 @@ impl Sample {

let raw_val = &self.buffer[vs..ve];

let v: Value;
v = match vt {
let v: Value = match vt {
Value::INT(_) => {
if vc == 1 {
Value::INT(i32::from_le_bytes(raw_val.try_into().unwrap()))
Expand Down Expand Up @@ -475,7 +474,7 @@ impl Sample {
}
Value::DOUBLE(_) => Value::DOUBLE(f64::from_le_bytes(raw_val.try_into().unwrap())),
Value::BITS(_) => Value::BITS(u32::from_le_bytes(raw_val.try_into().unwrap())),
Value::CHAR(_) => Value::CHAR(raw_val[0] as u8),
Value::CHAR(_) => Value::CHAR(raw_val[0]),
Value::BOOL(_) => {
if vc == 1 {
Value::BOOL(raw_val[0] > 0)
Expand Down Expand Up @@ -539,8 +538,8 @@ pub enum SampleError {
NoValue(String),
}

impl<'conn> Blocking<'conn> {
fn new(location: *const c_void) -> IOResult<Self> {
impl Blocking<'_> {
fn new(location: *const c_void) -> std::io::Result<Self> {
let mut event_name: Vec<u16> = DATA_EVENT_NAME.encode_utf16().collect();
event_name.push(0);

Expand Down Expand Up @@ -617,7 +616,7 @@ impl<'conn> Blocking<'conn> {
}
}

impl<'conn> Drop for Blocking<'conn> {
impl Drop for Blocking<'_> {
fn drop(&mut self) {
unsafe {
let succ = CloseHandle(self.event_handle);
Expand Down Expand Up @@ -800,7 +799,7 @@ mod tests {

#[test]
fn test_latest_telemetry() {
let session_tick: u32 = Connection::new()
let session_tick: Sample = Connection::new()
.expect("Unable to open telemetry")
.telemetry();
}
Expand Down
10 changes: 5 additions & 5 deletions src/track_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ impl From<i32> for TrackSurface {
match idx {
-1 => TrackSurface::NotInWorld,
0 => TrackSurface::Undefined,
1 | 2 | 3 | 4 => TrackSurface::Asphalt(ix),
1..=4 => TrackSurface::Asphalt(ix),
6 | 7 => TrackSurface::Concrete(ix - 4),
8 | 9 => TrackSurface::RacingDirt(ix - 7),
10 | 11 => TrackSurface::Paint(ix - 9),
12 | 13 | 14 | 15 => TrackSurface::Rumble(ix - 11),
16 | 17 | 18 | 19 => TrackSurface::Grass(ix - 15),
20 | 21 | 22 | 23 => TrackSurface::Dirt(ix - 19),
12..=15 => TrackSurface::Rumble(ix - 11),
16..=19 => TrackSurface::Grass(ix - 15),
20..=23 => TrackSurface::Dirt(ix - 19),
24 => TrackSurface::Sand,
25 | 26 | 27 | 28 => TrackSurface::Gravel(ix - 24),
25..=28 => TrackSurface::Gravel(ix - 24),
29 => TrackSurface::Grasscrete,
30 => TrackSurface::Astroturf,
_ => TrackSurface::Unknown(ix),
Expand Down
Loading