Skip to content
This repository has been archived by the owner on Sep 12, 2020. It is now read-only.

Commit

Permalink
Updated to Rust 2018 edition
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmnn committed Nov 8, 2018
1 parent c76a725 commit 84586db
Show file tree
Hide file tree
Showing 20 changed files with 71 additions and 80 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
authors = ["Altenius <[email protected]>"]
description = "Utilities for tuning vehicles"
respository = "https://github.com/LibreTuner/tuneutils"
edition = "2018"

[features]
socketcan = []
Expand Down
7 changes: 4 additions & 3 deletions src/authenticator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use protocols::uds;
use self::uds::UdsInterface;
use error::Result;
use crate::{
protocols::uds::{self, UdsInterface},
error::Result,
};

pub struct MazdaAuthenticator {

Expand Down
10 changes: 6 additions & 4 deletions src/datalog.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use numvariant::NumVariant;
use definition::{self, Pid};
use std::sync::atomic::{AtomicBool, Ordering};
use protocols::uds::UdsInterface;
use std::thread;
use std::time;
use std::cell::RefCell;
use std::rc::Rc;
use std::sync::{Arc, Mutex};

use error::Result;
use crate::{
protocols::uds::UdsInterface,
definition::{self, Pid},
numvariant::NumVariant,
error::Result,
};

extern crate eval;

Expand Down
2 changes: 1 addition & 1 deletion src/definition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::path::Path;
use std::fs;
use std::io::Read;

use error::Result;
use crate::error::Result;

#[serde(rename_all = "lowercase")]
#[derive(Debug, Serialize, Deserialize)]
Expand Down
9 changes: 5 additions & 4 deletions src/download/mazda.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use super::{Downloader, DownloadResponse, DownloadCallback};

use protocols::uds::UdsInterface;
use authenticator::MazdaAuthenticator;
use crate::{
protocols::uds::UdsInterface,
authenticator::MazdaAuthenticator,
error::{Error, Result},
};

use std::cmp;
use std::rc::Rc;

use error::{Error, Result};


pub struct Mazda1Downloader {
interface: Rc<UdsInterface>,
Expand Down
2 changes: 1 addition & 1 deletion src/download/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pub mod mazda;

use std::cell::RefCell;
use error::Result;
use crate::error::Result;

pub struct DownloadCallback {
pub callback: Option<Box<RefCell<FnMut(f32)>>>,
Expand Down
5 changes: 0 additions & 5 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
extern crate eval;
extern crate serde_yaml;
#[cfg(feature = "j2534")]
extern crate j2534;

use std::result;
use std::io;
use std::fmt;
Expand Down
13 changes: 6 additions & 7 deletions src/flash/mazda.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
extern crate byteorder;

use super::{Flasher, FlashData};

use error::Result;

use protocols::uds::{self, UdsInterface};
use authenticator::MazdaAuthenticator;
use crate::{
protocols::uds::{self, UdsInterface},
authenticator::MazdaAuthenticator,
error::Result,
};

use self::byteorder::{BigEndian, WriteBytesExt};
use byteorder::{BigEndian, WriteBytesExt};

use std::cmp;
use std::rc::Rc;
Expand Down
2 changes: 1 addition & 1 deletion src/flash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod mazda;

use std::cell::RefCell;

use error::Result;
use crate::error::Result;

pub struct FlashData<'a> {
pub offset: usize,
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ pub mod authenticator;
pub mod definition;
pub mod rom;
pub mod datalog;
pub mod diagnostics;

pub use self::error::{Error, Result};
30 changes: 15 additions & 15 deletions src/link.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#[cfg(feature = "socketcan")]
use protocols::can::socketcan::SocketCan;
use crate::protocols::can::socketcan::SocketCan;
#[cfg(feature = "j2534")]
use protocols::can::j2534can::J2534Can;
#[cfg(feature = "j2534")]
extern crate j2534;

use protocols::can::CanInterface;
use protocols::isotp::{self, IsotpInterface, IsotpCan};
use protocols::uds::{UdsIsotp, UdsInterface};

use download::{self, Downloader};
use flash::{self, Flasher};
use error::Result;

use definition::{self, DownloadMode, FlashMode, LogMode};
use datalog;
use crate::protocols::can::j2534can::J2534Can;

use crate::{
protocols::{
can::CanInterface,
isotp::{self, IsotpInterface, IsotpCan},
uds::{UdsIsotp, UdsInterface},
},
download::{self, Downloader},
flash::{self, Flasher},
definition::{self, DownloadMode, FlashMode, LogMode},
datalog,
error::Result,
};

use std::rc::Rc;
use std::time;
Expand Down
13 changes: 5 additions & 8 deletions src/protocols/can/j2534can.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
extern crate libc;
extern crate j2534;
extern crate byteorder;

use std::rc::Rc;
use std::time;
use self::byteorder::{WriteBytesExt, ReadBytesExt, BigEndian};
use byteorder::{WriteBytesExt, ReadBytesExt, BigEndian};
use std::io::{Write, Read};
use error::{Error, Result};

use protocols::can::{CanInterface, Message};
use crate::{
protocols::can::{CanInterface, Message},
error::{Error, Result};
};


impl From<j2534::Error> for Error {
Expand Down
8 changes: 2 additions & 6 deletions src/protocols/can/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#[cfg(feature = "j2534")]
extern crate j2534;
extern crate itertools;

use std::time;
use std::fmt;
use std::iter;
use error::Result;
use self::itertools::Itertools;
use crate::error::Result;
use itertools::Itertools;


#[cfg(feature = "j2534")]
Expand Down
4 changes: 1 addition & 3 deletions src/protocols/can/socketcan.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
extern crate libc;

use std::io;
use std::mem;
use std::time;
use std::ffi;

use super::{CanInterface, Message};
use error::{Error, Result};
use crate::error::{Error, Result};


const AF_CAN: libc::c_int = 29;
Expand Down
6 changes: 4 additions & 2 deletions src/protocols/isotp/can.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use protocols::can::CanInterface;
use crate::{
protocols::can::CanInterface,
error::{Error, Result},
};

use super::{IsotpInterface, Frame, Options, FCFlag, FlowControlFrame, FirstFrame, SingleFrame};
use std::cmp;
use std::time;
use std::thread;
use std::rc::Rc;
use error::{Error, Result};

pub struct IsotpCan {
can: Rc<CanInterface>,
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/isotp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::default::Default;
pub mod can;

pub use self::can::IsotpCan;
use error::{Error, Result};
use crate::error::{Error, Result};

use std::cmp;

Expand Down
9 changes: 5 additions & 4 deletions src/protocols/uds/isotp.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use protocols::isotp::IsotpInterface;
use crate::{
protocols::isotp::IsotpInterface,
error::{Error, Result},
};
use super::{UdsInterface, UDS_NRES_RCRRP};

use std::rc::Rc;

use super::{UdsInterface, UDS_NRES_RCRRP};
use error::{Error, Result};

pub struct UdsIsotp {
interface: Rc<IsotpInterface>,
}
Expand Down
6 changes: 2 additions & 4 deletions src/protocols/uds/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
extern crate byteorder;

pub mod isotp;

pub use self::isotp::UdsIsotp;

use error::{Error, Result};
use crate::error::{Error, Result};

use self::byteorder::{BigEndian, WriteBytesExt};
use byteorder::{BigEndian, WriteBytesExt};

pub struct Response {
pub data: Vec<u8>,
Expand Down
7 changes: 4 additions & 3 deletions src/rom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ use std::collections::HashMap;
use std::fs;
use std::path::{Path, PathBuf};

use error::{Error, Result};
use crate::{
error::{Error, Result},
definition,
};

pub mod tune;

use definition;


#[derive(Debug)]
pub struct Rom {
Expand Down
14 changes: 6 additions & 8 deletions src/rom/tune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ use self::byteorder::{ByteOrder, BigEndian, LittleEndian, ReadBytesExt, WriteByt

use super::{Rom, RomManager};

use error::{Error, Result};

use definition::{DataType, Endianness};
use definition::Table as TableDefinition;

use numvariant::NumVariant;

use crate::{
error::{Error, Result},
definition::{self, DataType, Endianness},
numvariant::NumVariant,
};



Expand Down Expand Up @@ -226,7 +224,7 @@ pub struct Table {

impl Table {
/// Loads a table from the definition and raw data
pub fn load_raw(definition: &TableDefinition, data: &[u8], endianness: Endianness) -> Result<Table> {
pub fn load_raw(definition: &definition::Table, data: &[u8], endianness: Endianness) -> Result<Table> {
let size = definition.width * definition.height;
let data = match endianness {
Endianness::Big => deserialize_table::<BigEndian>(definition.data_type, data, size)?,
Expand Down

0 comments on commit 84586db

Please sign in to comment.