diff --git a/Cargo.toml b/Cargo.toml index 19504079..d945356a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "common", "datafile", diff --git a/common/Cargo.toml b/common/Cargo.toml index 5f0a8123..2836a5e8 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -3,6 +3,7 @@ name = "common" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = "0.5.2" diff --git a/common/benches/cast.rs b/common/benches/cast.rs index 9bca325c..17fc15c0 100644 --- a/common/benches/cast.rs +++ b/common/benches/cast.rs @@ -1,7 +1,5 @@ -#[macro_use] -extern crate bencher; -extern crate common; - +use bencher::benchmark_group; +use bencher::benchmark_main; use bencher::black_box; use bencher::Bencher; use common::num::Cast; diff --git a/common/src/io.rs b/common/src/io.rs index 6261fb24..584ca49c 100644 --- a/common/src/io.rs +++ b/common/src/io.rs @@ -47,7 +47,7 @@ pub trait FileExt { #[cfg(feature = "file_offset")] impl FileExt for std::fs::File { fn read_offset_retry(&self, buffer: &mut [u8], offset: u64) -> io::Result { - use num::Cast; + use crate::num::Cast; // Make sure the additions in this function don't overflow let _end_offset = offset diff --git a/common/src/lib.rs b/common/src/lib.rs index 1b14c795..4069ab39 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -1,18 +1,7 @@ -#[cfg(test)] -#[macro_use] -extern crate quickcheck; - -extern crate arrayvec; -#[cfg(feature = "file_offset")] -extern crate file_offset; -#[cfg(feature = "serde")] -extern crate serde; -extern crate zerocopy; - -pub use map_iter::MapIterator; -pub use slice::relative_size_of; -pub use slice::relative_size_of_mult; -pub use takeable::Takeable; +pub use self::map_iter::MapIterator; +pub use self::slice::relative_size_of; +pub use self::slice::relative_size_of_mult; +pub use self::takeable::Takeable; #[macro_use] mod macros; diff --git a/common/src/str.rs b/common/src/str.rs index c8264d44..5d75b60e 100644 --- a/common/src/str.rs +++ b/common/src/str.rs @@ -18,6 +18,7 @@ pub fn truncated_arraystring + Copy>(mut s: &str) -> ArraySt #[cfg(test)] mod test { use super::truncated_arraystring; + use quickcheck::quickcheck; quickcheck! { fn truncated_arraystring0(v: String) -> bool { truncated_arraystring::<[u8; 0]>(&v); diff --git a/common/src/vec.rs b/common/src/vec.rs index 41a69a93..9bf4945b 100644 --- a/common/src/vec.rs +++ b/common/src/vec.rs @@ -1,8 +1,7 @@ +use crate::relative_size_of_mult; +use crate::slice; use std::mem; -use relative_size_of_mult; -use slice; - pub unsafe fn transmute(vec: Vec) -> Vec { slice::transmute::(&vec); // Error checking done there. diff --git a/datafile/Cargo.toml b/datafile/Cargo.toml index 06fede28..1deb5287 100644 --- a/datafile/Cargo.toml +++ b/datafile/Cargo.toml @@ -3,6 +3,7 @@ name = "datafile" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] common = { path = "../common/", features = ["file_offset"] } @@ -10,4 +11,4 @@ hexdump = "0.1.1" itertools = ">=0.3.0,<0.5.0" log = "0.3.0" logger = { path = "../logger/" } -zlib_minimal = { path = "../zlib_minimal/" } +zlib = { package = "zlib_minimal", path = "../zlib_minimal/" } diff --git a/datafile/src/bitmagic.rs b/datafile/src/bitmagic.rs index a76562b2..74b9a5d9 100644 --- a/datafile/src/bitmagic.rs +++ b/datafile/src/bitmagic.rs @@ -1,11 +1,10 @@ +use crate::format::OnlyI32; +use crate::raw::CallbackError; +use crate::raw::CallbackNew; +use crate::raw::CallbackReadData; +use crate::raw::CallbackReadError; use std::mem; -use format::OnlyI32; -use raw::CallbackError; -use raw::CallbackNew; -use raw::CallbackReadData; -use raw::CallbackReadError; - pub use common::relative_size_of; pub use common::relative_size_of_mult; pub use common::slice::transmute as transmute_slice; diff --git a/datafile/src/buffer.rs b/datafile/src/buffer.rs index 8a84810a..10164b97 100644 --- a/datafile/src/buffer.rs +++ b/datafile/src/buffer.rs @@ -1,5 +1,5 @@ +use crate::format::ItemView; use common::MapIterator; -use format::ItemView; use std::ops; #[derive(Clone, Copy, Debug)] diff --git a/datafile/src/file.rs b/datafile/src/file.rs index 99ef39bf..0d7bfa5e 100644 --- a/datafile/src/file.rs +++ b/datafile/src/file.rs @@ -1,3 +1,9 @@ +use crate::format; +use crate::format::ItemView; +use crate::raw; +use crate::raw::CallbackError; +use crate::raw::CallbackNew; +use crate::raw::CallbackReadData; use common::io::seek_overflow; use common::io::FileExt; use common::io::ReadExt; @@ -11,13 +17,6 @@ use std::io::SeekFrom; use std::ops; use std::path::Path; -use format; -use format::ItemView; -use raw; -use raw::CallbackError; -use raw::CallbackNew; -use raw::CallbackReadData; - #[derive(Debug)] pub enum Error { Df(format::Error), diff --git a/datafile/src/format.rs b/datafile/src/format.rs index 2d082cb6..9846ab93 100644 --- a/datafile/src/format.rs +++ b/datafile/src/format.rs @@ -1,13 +1,11 @@ -use std::mem; - -use bitmagic::as_mut_i32_slice; -use bitmagic::to_little_endian; -use bitmagic::CallbackNewExt; +use crate::bitmagic::as_mut_i32_slice; +use crate::bitmagic::to_little_endian; +use crate::bitmagic::CallbackNewExt; +use crate::raw; +use crate::raw::CallbackNew; use common::num::Cast; -use raw; -use raw::CallbackNew; +use std::mem; use std::slice; -use zlib; #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub enum Error { diff --git a/datafile/src/lib.rs b/datafile/src/lib.rs index da05343a..0d7f61ad 100644 --- a/datafile/src/lib.rs +++ b/datafile/src/lib.rs @@ -1,20 +1,15 @@ #[macro_use] extern crate log; -extern crate common; -extern crate hexdump; -extern crate itertools; -extern crate zlib_minimal as zlib; - -pub use file::DataIter; -pub use file::Error; -pub use file::Reader; -pub use format::ItemView; -pub use format::OnlyI32; -pub use raw::ItemTypeItems; -pub use raw::ItemTypes; -pub use raw::Items; -pub use raw::Version; +pub use self::file::DataIter; +pub use self::file::Error; +pub use self::file::Reader; +pub use self::format::ItemView; +pub use self::format::OnlyI32; +pub use self::raw::ItemTypeItems; +pub use self::raw::ItemTypes; +pub use self::raw::Items; +pub use self::raw::Version; mod bitmagic; pub mod buffer; diff --git a/datafile/src/raw.rs b/datafile/src/raw.rs index 86b77501..81173e02 100644 --- a/datafile/src/raw.rs +++ b/datafile/src/raw.rs @@ -1,21 +1,18 @@ +use crate::bitmagic::relative_size_of; +use crate::bitmagic::relative_size_of_mult; +use crate::bitmagic::transmute_slice; +use crate::bitmagic::CallbackNewExt; +use crate::bitmagic::CallbackReadDataExt; +use crate::format; +use crate::format::ItemView; +use crate::format::OnlyI32; use common::num::Cast; use common::MapIterator; use hexdump::hexdump_iter; use hexdump::sanitize_byte; use itertools::Itertools; -use log; use std::mem; use std::ops; -use zlib; - -use bitmagic::relative_size_of; -use bitmagic::relative_size_of_mult; -use bitmagic::transmute_slice; -use bitmagic::CallbackNewExt; -use bitmagic::CallbackReadDataExt; -use format; -use format::ItemView; -use format::OnlyI32; #[derive(Clone, Copy, Eq, Hash, PartialEq, Debug)] pub enum Version { diff --git a/demo/Cargo.toml b/demo/Cargo.toml index 8e1c68a3..5388de2e 100644 --- a/demo/Cargo.toml +++ b/demo/Cargo.toml @@ -3,7 +3,7 @@ name = "demo" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] arrayvec = "0.5.2" diff --git a/demo/src/ddnet.rs b/demo/src/ddnet.rs index d45d5f84..5145f82f 100644 --- a/demo/src/ddnet.rs +++ b/demo/src/ddnet.rs @@ -1,9 +1,9 @@ mod reader; mod writer; -pub use reader::Chunk; -pub use reader::DemoReader; -pub use reader::ReadError; -pub use reader::Warning; -pub use writer::DemoWriter; -pub use writer::WriteError; +pub use self::reader::Chunk; +pub use self::reader::DemoReader; +pub use self::reader::ReadError; +pub use self::reader::Warning; +pub use self::writer::DemoWriter; +pub use self::writer::WriteError; diff --git a/demo/src/format.rs b/demo/src/format.rs index a6c78206..f82d8ecd 100644 --- a/demo/src/format.rs +++ b/demo/src/format.rs @@ -5,7 +5,6 @@ use common::digest::Sha256; use common::num::Cast; use std::convert::TryFrom; use std::io; -use warn; use warn::Warn; pub const MAX_SNAPSHOT_SIZE: usize = 65536; diff --git a/demo/src/lib.rs b/demo/src/lib.rs index 87c49455..ed12179a 100644 --- a/demo/src/lib.rs +++ b/demo/src/lib.rs @@ -1,27 +1,13 @@ -extern crate arrayvec; -extern crate binrw; -extern crate buffer; -extern crate common; -extern crate gamenet_common; -extern crate gamenet_ddnet; -extern crate huffman; -#[macro_use] -extern crate matches; -extern crate packer; -extern crate snapshot; -extern crate thiserror; -extern crate warn; - pub mod ddnet; mod format; mod reader; mod writer; -pub use format::DemoKind; -pub use format::RawChunk; -pub use format::Version; -pub use format::Warning; -pub use reader::ReadError; -pub use reader::Reader; -pub use writer::WriteError; -pub use writer::Writer; +pub use self::format::DemoKind; +pub use self::format::RawChunk; +pub use self::format::Version; +pub use self::format::Warning; +pub use self::reader::ReadError; +pub use self::reader::Reader; +pub use self::writer::WriteError; +pub use self::writer::Writer; diff --git a/demo/src/reader.rs b/demo/src/reader.rs index 1cec9bc8..6aac0f4b 100644 --- a/demo/src/reader.rs +++ b/demo/src/reader.rs @@ -2,9 +2,7 @@ use arrayvec::ArrayVec; use binrw::BinRead; use common::digest::Sha256; use common::num::Cast; -use huffman; use huffman::instances::TEEWORLDS as HUFFMAN; -use packer; use std::io; use thiserror::Error; use warn::wrap; diff --git a/demo/src/writer.rs b/demo/src/writer.rs index f2c7be41..7078cd96 100644 --- a/demo/src/writer.rs +++ b/demo/src/writer.rs @@ -1,6 +1,5 @@ use arrayvec::ArrayVec; use binrw::BinWrite; -use buffer; use common::digest::Sha256; use common::num::Cast; use huffman::instances::TEEWORLDS as HUFFMAN; diff --git a/downloader/Cargo.toml b/downloader/Cargo.toml index 473f57c8..a65bed48 100644 --- a/downloader/Cargo.toml +++ b/downloader/Cargo.toml @@ -3,13 +3,14 @@ name = "downloader" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = "0.5.2" clap = "2.31.2" common = { path = "../common/" } event_loop = { path = "../event_loop/" } -gamenet_teeworlds_0_6 = { path = "../gamenet/teeworlds-0.6/" } +gamenet = { package = "gamenet_teeworlds_0_6", path = "../gamenet/teeworlds-0.6/" } hexdump = "0.1.1" itertools = ">=0.3.0,<0.5.0" log = "0.3.1" diff --git a/downloader/src/main.rs b/downloader/src/main.rs index 49382853..98a503a5 100644 --- a/downloader/src/main.rs +++ b/downloader/src/main.rs @@ -1,21 +1,8 @@ -extern crate arrayvec; -#[macro_use] -extern crate clap; -extern crate common; -extern crate event_loop; -extern crate gamenet_teeworlds_0_6 as gamenet; -extern crate hexdump; -extern crate itertools; #[macro_use] extern crate log; -extern crate logger; -extern crate packer; -extern crate rand; -extern crate snapshot; -extern crate tempfile; -extern crate warn; use arrayvec::ArrayVec; +use clap::values_t; use clap::App; use clap::Arg; use clap::Error; diff --git a/event_loop/Cargo.toml b/event_loop/Cargo.toml index 3ec60779..098c691b 100644 --- a/event_loop/Cargo.toml +++ b/event_loop/Cargo.toml @@ -3,6 +3,7 @@ name = "event_loop" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = "0.5.2" diff --git a/event_loop/src/lib.rs b/event_loop/src/lib.rs index 9009cccd..f167f93f 100644 --- a/event_loop/src/lib.rs +++ b/event_loop/src/lib.rs @@ -1,13 +1,5 @@ -extern crate arrayvec; -extern crate common; -extern crate hexdump; -extern crate itertools; #[macro_use] extern crate log; -extern crate logger; -extern crate net; -extern crate socket; -extern crate warn; use arrayvec::ArrayVec; use common::Takeable; diff --git a/gamenet/common/Cargo.toml b/gamenet/common/Cargo.toml index d4beeb8e..c1cef74d 100644 --- a/gamenet/common/Cargo.toml +++ b/gamenet/common/Cargo.toml @@ -3,6 +3,7 @@ name = "gamenet_common" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = "0.5.2" diff --git a/gamenet/common/src/error.rs b/gamenet/common/src/error.rs index 753c8240..0cc5f5ab 100644 --- a/gamenet/common/src/error.rs +++ b/gamenet/common/src/error.rs @@ -1,5 +1,3 @@ -use packer; - #[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub enum Error { ControlCharacters, diff --git a/gamenet/common/src/lib.rs b/gamenet/common/src/lib.rs index fb8317b1..7a38818d 100644 --- a/gamenet/common/src/lib.rs +++ b/gamenet/common/src/lib.rs @@ -1,14 +1,3 @@ -extern crate arrayvec; -extern crate buffer; -extern crate common; -extern crate packer; -extern crate serde; -#[macro_use] -extern crate serde_derive; -extern crate uuid; -extern crate warn; -extern crate zerocopy; - pub mod debug; pub mod error; pub mod msg; diff --git a/gamenet/common/src/msg.rs b/gamenet/common/src/msg.rs index 97e4ab7e..5745d5ae 100644 --- a/gamenet/common/src/msg.rs +++ b/gamenet/common/src/msg.rs @@ -1,12 +1,14 @@ +use crate::error::Error; +use crate::error::InvalidIntString; use arrayvec::ArrayVec; use buffer::CapacityError; use common::slice; -use error::Error; -use error::InvalidIntString; use packer::ExcessData; use packer::Packer; use packer::Unpacker; use packer::Warning; +use serde_derive::Deserialize; +use serde_derive::Serialize; use std::fmt; use std::io::Write; use std::mem; diff --git a/gamenet/common/src/snap_obj.rs b/gamenet/common/src/snap_obj.rs index 34a0dda4..41eb9c80 100644 --- a/gamenet/common/src/snap_obj.rs +++ b/gamenet/common/src/snap_obj.rs @@ -1,3 +1,5 @@ +use serde_derive::Deserialize; +use serde_derive::Serialize; use std::fmt; use uuid::Uuid; diff --git a/gamenet/ddnet/Cargo.toml b/gamenet/ddnet/Cargo.toml index aa7dac0c..8a994677 100644 --- a/gamenet/ddnet/Cargo.toml +++ b/gamenet/ddnet/Cargo.toml @@ -3,6 +3,7 @@ name = "gamenet_ddnet" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = "0.5.2" diff --git a/gamenet/ddnet/src/lib.rs b/gamenet/ddnet/src/lib.rs index 34ebc8cb..34cc3cea 100644 --- a/gamenet/ddnet/src/lib.rs +++ b/gamenet/ddnet/src/lib.rs @@ -1,11 +1,3 @@ -extern crate arrayvec; -extern crate buffer; -extern crate common; -extern crate gamenet_common; -extern crate packer; -extern crate uuid; -extern crate warn; - #[rustfmt::skip] pub mod enums; #[rustfmt::skip] @@ -13,6 +5,6 @@ pub mod msg; #[rustfmt::skip] pub mod snap_obj; +pub use self::snap_obj::SnapObj; pub use gamenet_common::error; pub use gamenet_common::error::Error; -pub use snap_obj::SnapObj; diff --git a/gamenet/ddnet/src/msg/connless.rs b/gamenet/ddnet/src/msg/connless.rs index de6b9b07..e0313375 100644 --- a/gamenet/ddnet/src/msg/connless.rs +++ b/gamenet/ddnet/src/msg/connless.rs @@ -1,6 +1,6 @@ use buffer::CapacityError; use common::pretty; -use error::Error; +use crate::error::Error; use gamenet_common::msg::AddrPackedSliceExt; use gamenet_common::msg::int_from_string; use gamenet_common::msg::string_from_int; diff --git a/gamenet/ddnet/src/msg/game.rs b/gamenet/ddnet/src/msg/game.rs index bc910ea6..573351bb 100644 --- a/gamenet/ddnet/src/msg/game.rs +++ b/gamenet/ddnet/src/msg/game.rs @@ -1,7 +1,7 @@ use buffer::CapacityError; use common::pretty; -use enums; -use error::Error; +use crate::enums; +use crate::error::Error; use gamenet_common::debug::DebugSlice; use packer::Packer; use packer::Unpacker; diff --git a/gamenet/ddnet/src/msg/system.rs b/gamenet/ddnet/src/msg/system.rs index ae169508..1377f116 100644 --- a/gamenet/ddnet/src/msg/system.rs +++ b/gamenet/ddnet/src/msg/system.rs @@ -1,7 +1,7 @@ use buffer::CapacityError; use common::digest::Sha256; use common::pretty; -use error::Error; +use crate::error::Error; use packer::Packer; use packer::Unpacker; use packer::Warning; @@ -520,7 +520,7 @@ pub struct Input { pub ack_snapshot: i32, pub intended_tick: i32, pub input_size: i32, - pub input: ::snap_obj::PlayerInput, + pub input: crate::snap_obj::PlayerInput, } #[derive(Clone, Copy)] @@ -928,7 +928,7 @@ impl Input { ack_snapshot: _p.read_int(warn)?, intended_tick: _p.read_int(warn)?, input_size: _p.read_int(warn)?, - input: ::snap_obj::PlayerInput::decode_msg(warn, _p)?, + input: crate::snap_obj::PlayerInput::decode_msg(warn, _p)?, }); _p.finish(warn); result diff --git a/gamenet/ddnet/src/snap_obj.rs b/gamenet/ddnet/src/snap_obj.rs index ee812c6d..e2c0291d 100644 --- a/gamenet/ddnet/src/snap_obj.rs +++ b/gamenet/ddnet/src/snap_obj.rs @@ -1,7 +1,7 @@ use buffer::CapacityError; use common::slice; -use enums; -use error::Error; +use crate::enums; +use crate::error::Error; use packer::ExcessData; use packer::IntUnpacker; use packer::Packer; @@ -558,7 +558,7 @@ pub struct Projectile { pub vel_x: i32, pub vel_y: i32, pub type_: enums::Weapon, - pub start_tick: ::snap_obj::Tick, + pub start_tick: crate::snap_obj::Tick, } #[repr(C)] @@ -568,7 +568,7 @@ pub struct Laser { pub y: i32, pub from_x: i32, pub from_y: i32, - pub start_tick: ::snap_obj::Tick, + pub start_tick: crate::snap_obj::Tick, } #[repr(C)] @@ -593,7 +593,7 @@ pub struct Flag { pub struct GameInfo { pub game_flags: i32, pub game_state_flags: i32, - pub round_start_tick: ::snap_obj::Tick, + pub round_start_tick: crate::snap_obj::Tick, pub warmup_timer: i32, pub score_limit: i32, pub time_limit: i32, @@ -623,7 +623,7 @@ pub struct CharacterCore { pub jumped: i32, pub hooked_player: i32, pub hook_state: i32, - pub hook_tick: ::snap_obj::Tick, + pub hook_tick: crate::snap_obj::Tick, pub hook_x: i32, pub hook_y: i32, pub hook_dx: i32, @@ -683,13 +683,13 @@ pub struct MyOwnObject { #[derive(Clone, Copy)] pub struct DdnetCharacter { pub flags: i32, - pub freeze_end: ::snap_obj::Tick, + pub freeze_end: crate::snap_obj::Tick, pub jumps: i32, pub tele_checkpoint: i32, pub strong_weak_id: i32, pub jumped_total: i32, - pub ninja_activation_tick: ::snap_obj::Tick, - pub freeze_start: ::snap_obj::Tick, + pub ninja_activation_tick: crate::snap_obj::Tick, + pub freeze_start: crate::snap_obj::Tick, pub target_x: i32, pub target_y: i32, } @@ -717,7 +717,7 @@ pub struct DdraceProjectile { pub angle: i32, pub data: i32, pub type_: enums::Weapon, - pub start_tick: ::snap_obj::Tick, + pub start_tick: crate::snap_obj::Tick, } #[repr(C)] @@ -727,7 +727,7 @@ pub struct DdnetLaser { pub to_y: i32, pub from_x: i32, pub from_y: i32, - pub start_tick: ::snap_obj::Tick, + pub start_tick: crate::snap_obj::Tick, pub owner: i32, pub type_: i32, pub switch_number: i32, @@ -742,7 +742,7 @@ pub struct DdnetProjectile { pub vel_x: i32, pub vel_y: i32, pub type_: enums::Weapon, - pub start_tick: ::snap_obj::Tick, + pub start_tick: crate::snap_obj::Tick, pub owner: i32, pub switch_number: i32, pub tune_zone: i32, @@ -939,7 +939,7 @@ impl Projectile { vel_x: _p.read_int()?, vel_y: _p.read_int()?, type_: enums::Weapon::from_i32(_p.read_int()?)?, - start_tick: ::snap_obj::Tick(_p.read_int()?), + start_tick: crate::snap_obj::Tick(_p.read_int()?), }) } pub fn encode(&self) -> &[i32] { @@ -970,7 +970,7 @@ impl Laser { y: _p.read_int()?, from_x: _p.read_int()?, from_y: _p.read_int()?, - start_tick: ::snap_obj::Tick(_p.read_int()?), + start_tick: crate::snap_obj::Tick(_p.read_int()?), }) } pub fn encode(&self) -> &[i32] { @@ -1061,7 +1061,7 @@ impl GameInfo { Ok(GameInfo { game_flags: in_range(_p.read_int()?, 0, 256)?, game_state_flags: in_range(_p.read_int()?, 0, 256)?, - round_start_tick: ::snap_obj::Tick(_p.read_int()?), + round_start_tick: crate::snap_obj::Tick(_p.read_int()?), warmup_timer: _p.read_int()?, score_limit: positive(_p.read_int()?)?, time_limit: positive(_p.read_int()?)?, @@ -1150,7 +1150,7 @@ impl CharacterCore { jumped: in_range(_p.read_int()?, 0, 3)?, hooked_player: in_range(_p.read_int()?, -1, 63)?, hook_state: in_range(_p.read_int()?, -1, 5)?, - hook_tick: ::snap_obj::Tick(_p.read_int()?), + hook_tick: crate::snap_obj::Tick(_p.read_int()?), hook_x: _p.read_int()?, hook_y: _p.read_int()?, hook_dx: _p.read_int()?, @@ -1370,13 +1370,13 @@ impl DdnetCharacter { pub fn decode_inner(_p: &mut IntUnpacker) -> Result { Ok(DdnetCharacter { flags: _p.read_int()?, - freeze_end: ::snap_obj::Tick(_p.read_int()?), + freeze_end: crate::snap_obj::Tick(_p.read_int()?), jumps: in_range(_p.read_int()?, -1, 255)?, tele_checkpoint: _p.read_int()?, strong_weak_id: in_range(_p.read_int()?, 0, 63)?, jumped_total: in_range(_p.read_int()?, -1, 255)?, - ninja_activation_tick: ::snap_obj::Tick(_p.read_int()?), - freeze_start: ::snap_obj::Tick(_p.read_int()?), + ninja_activation_tick: crate::snap_obj::Tick(_p.read_int()?), + freeze_start: crate::snap_obj::Tick(_p.read_int()?), target_x: _p.read_int()?, target_y: _p.read_int()?, }) @@ -1467,7 +1467,7 @@ impl DdraceProjectile { angle: _p.read_int()?, data: _p.read_int()?, type_: enums::Weapon::from_i32(_p.read_int()?)?, - start_tick: ::snap_obj::Tick(_p.read_int()?), + start_tick: crate::snap_obj::Tick(_p.read_int()?), }) } pub fn encode(&self) -> &[i32] { @@ -1502,7 +1502,7 @@ impl DdnetLaser { to_y: _p.read_int()?, from_x: _p.read_int()?, from_y: _p.read_int()?, - start_tick: ::snap_obj::Tick(_p.read_int()?), + start_tick: crate::snap_obj::Tick(_p.read_int()?), owner: in_range(_p.read_int()?, -1, 63)?, type_: _p.read_int()?, switch_number: _p.read_int()?, @@ -1544,7 +1544,7 @@ impl DdnetProjectile { vel_x: _p.read_int()?, vel_y: _p.read_int()?, type_: enums::Weapon::from_i32(_p.read_int()?)?, - start_tick: ::snap_obj::Tick(_p.read_int()?), + start_tick: crate::snap_obj::Tick(_p.read_int()?), owner: in_range(_p.read_int()?, -1, 63)?, switch_number: _p.read_int()?, tune_zone: _p.read_int()?, diff --git a/gamenet/generate/datatypes.py b/gamenet/generate/datatypes.py index 23a59a3b..b42bf559 100644 --- a/gamenet/generate/datatypes.py +++ b/gamenet/generate/datatypes.py @@ -213,7 +213,7 @@ def emit_header_snap_obj(): def emit_header_msg_system(): import_( "buffer::CapacityError", - "error::Error", + "crate::error::Error", "packer::Packer", "packer::Unpacker", "packer::Warning", @@ -245,7 +245,7 @@ def emit_header_msg_system(): def emit_header_msg_game(): import_( "buffer::CapacityError", - "error::Error", + "crate::error::Error", "packer::Packer", "packer::Unpacker", "packer::Warning", @@ -280,7 +280,7 @@ def emit_header_msg_connless(structs): import_( "buffer::CapacityError", "common::pretty", - "error::Error", + "crate::error::Error", "packer::Packer", "packer::Unpacker", "packer::Warning", @@ -363,7 +363,7 @@ def emit_enum_from(name, structs): def emit_enum_msg(name, structs): import_( "buffer::CapacityError", - "error::Error", + "crate::error::Error", "packer::Packer", "packer::Unpacker", "packer::Warning", @@ -425,7 +425,7 @@ def emit_enum_msg_module(name, structs): def emit_enum_obj(name, structs): import_( - "error::Error", + "crate::error::Error", "packer::ExcessData", "packer::IntUnpacker", "std::fmt", @@ -492,7 +492,7 @@ def emit_enum_obj_module(name, structs, flags): def emit_enum_connless(name, structs): import_( "buffer::CapacityError", - "error::Error", + "crate::error::Error", "packer::Warning", "std::fmt", "warn::Warn", @@ -574,6 +574,7 @@ def emit_cargo_toml(name): version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = "0.5.2" @@ -587,14 +588,6 @@ def emit_cargo_toml(name): def emit_main_lib(): print("""\ -extern crate arrayvec; -extern crate buffer; -extern crate common; -extern crate gamenet_common; -extern crate packer; -extern crate uuid; -extern crate warn; - #[rustfmt::skip] pub mod enums; #[rustfmt::skip] @@ -602,9 +595,9 @@ def emit_main_lib(): #[rustfmt::skip] pub mod snap_obj; +pub use self::snap_obj::SnapObj; pub use gamenet_common::error; -pub use gamenet_common::error::Error; -pub use snap_obj::SnapObj;\ +pub use gamenet_common::error::Error;\ """) def emit_msg_module(): @@ -814,7 +807,7 @@ def emit_definition(self): def emit_impl_encode_decode(self, suffix=False): import_( "buffer::CapacityError", - "error::Error", + "crate::error::Error", "packer::Packer", "packer::Unpacker", "packer::Warning", @@ -914,7 +907,7 @@ def emit_definition(self): def emit_impl_encode_decode_int(self): import_( "common::slice", - "error::Error", + "crate::error::Error", "packer::ExcessData", "packer::IntUnpacker", "std::slice::from_ref", @@ -1339,12 +1332,12 @@ def __init__(self, name, enum_name): self.enum_name = canonicalize(enum_name) self.type_ = "enums::{}".format(title(self.enum_name)) def decode_expr(self): - import_("enums") + import_("crate::enums") return "enums::{}::from_i32({})?".format(title(self.enum_name), super().decode_expr()) def encode_expr(self, self_expr): return super().encode_expr("{}.to_i32()".format(self_expr)) def decode_int_expr(self): - import_("enums") + import_("crate::enums") return "enums::{}::from_i32({})?".format(title(self.enum_name), super().decode_int_expr()) def serialize_type(self): return {"kind": self.kind, "enum": self.enum_name} @@ -1397,13 +1390,13 @@ def deserialize(name, json_obj): class NetTick(NetIntAny): kind = "tick" - type_ = "::snap_obj::Tick" + type_ = "crate::snap_obj::Tick" def decode_expr(self): - return "::snap_obj::Tick({})".format(super().decode_expr()) + return "crate::snap_obj::Tick({})".format(super().decode_expr()) def encode_expr(self, self_expr): return super().encode_expr("{}.0".format(self_expr)) def decode_int_expr(self): - return "::snap_obj::Tick({})".format(super().decode_int_expr()) + return "crate::snap_obj::Tick({})".format(super().decode_int_expr()) def serialize_type(self): return {"kind": self.kind} @staticmethod @@ -1414,7 +1407,7 @@ class NetObjectMember(Member): kind = "snapshot_object" def __init__(self, name, type_): super().__init__(name) - self.type_ = "::snap_obj::{}".format(title(type_)) + self.type_ = "crate::snap_obj::{}".format(title(type_)) self.type_name = type_ def decode_expr(self): return "{}::decode_msg(warn, _p)?".format(self.type_) diff --git a/gamenet/spec/Cargo.toml b/gamenet/spec/Cargo.toml index e8089938..d18408e2 100644 --- a/gamenet/spec/Cargo.toml +++ b/gamenet/spec/Cargo.toml @@ -3,6 +3,7 @@ name = "gamenet_spec" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] gamenet_common = { path = "../common/" } diff --git a/gamenet/spec/src/lib.rs b/gamenet/spec/src/lib.rs index 3d306f8e..156e29bb 100644 --- a/gamenet/spec/src/lib.rs +++ b/gamenet/spec/src/lib.rs @@ -1,9 +1,5 @@ -extern crate gamenet_common; -extern crate serde; -#[macro_use] -extern crate serde_derive; -extern crate uuid; - +use serde_derive::Deserialize; +use serde_derive::Serialize; use std::collections::HashSet; pub use gamenet_common::msg::MessageId; diff --git a/gamenet/teeworlds-0.5/Cargo.toml b/gamenet/teeworlds-0.5/Cargo.toml index 71fc3d7e..8fba1496 100644 --- a/gamenet/teeworlds-0.5/Cargo.toml +++ b/gamenet/teeworlds-0.5/Cargo.toml @@ -3,6 +3,7 @@ name = "gamenet_teeworlds_0_5" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = "0.5.2" diff --git a/gamenet/teeworlds-0.5/src/lib.rs b/gamenet/teeworlds-0.5/src/lib.rs index 34ebc8cb..34cc3cea 100644 --- a/gamenet/teeworlds-0.5/src/lib.rs +++ b/gamenet/teeworlds-0.5/src/lib.rs @@ -1,11 +1,3 @@ -extern crate arrayvec; -extern crate buffer; -extern crate common; -extern crate gamenet_common; -extern crate packer; -extern crate uuid; -extern crate warn; - #[rustfmt::skip] pub mod enums; #[rustfmt::skip] @@ -13,6 +5,6 @@ pub mod msg; #[rustfmt::skip] pub mod snap_obj; +pub use self::snap_obj::SnapObj; pub use gamenet_common::error; pub use gamenet_common::error::Error; -pub use snap_obj::SnapObj; diff --git a/gamenet/teeworlds-0.5/src/msg/connless.rs b/gamenet/teeworlds-0.5/src/msg/connless.rs index 1d6f7872..cbcdc974 100644 --- a/gamenet/teeworlds-0.5/src/msg/connless.rs +++ b/gamenet/teeworlds-0.5/src/msg/connless.rs @@ -1,6 +1,6 @@ use buffer::CapacityError; use common::pretty; -use error::Error; +use crate::error::Error; use gamenet_common::msg::string_from_int; use packer::Packer; use packer::Unpacker; diff --git a/gamenet/teeworlds-0.5/src/msg/game.rs b/gamenet/teeworlds-0.5/src/msg/game.rs index c8cfb1b6..cf8f5b30 100644 --- a/gamenet/teeworlds-0.5/src/msg/game.rs +++ b/gamenet/teeworlds-0.5/src/msg/game.rs @@ -1,7 +1,7 @@ use buffer::CapacityError; use common::pretty; -use enums; -use error::Error; +use crate::enums; +use crate::error::Error; use packer::Packer; use packer::Unpacker; use packer::Warning; @@ -397,7 +397,7 @@ pub struct SvTuneParams { #[derive(Clone, Copy)] pub struct SvExtraProjectile { - pub projectile: ::snap_obj::Projectile, + pub projectile: crate::snap_obj::Projectile, } #[derive(Clone, Copy)] @@ -765,7 +765,7 @@ impl fmt::Debug for SvTuneParams { impl SvExtraProjectile { pub fn decode>(warn: &mut W, _p: &mut Unpacker) -> Result { let result = Ok(SvExtraProjectile { - projectile: ::snap_obj::Projectile::decode_msg(warn, _p)?, + projectile: crate::snap_obj::Projectile::decode_msg(warn, _p)?, }); _p.finish(warn); result diff --git a/gamenet/teeworlds-0.5/src/msg/system.rs b/gamenet/teeworlds-0.5/src/msg/system.rs index dc8d2446..be2633f1 100644 --- a/gamenet/teeworlds-0.5/src/msg/system.rs +++ b/gamenet/teeworlds-0.5/src/msg/system.rs @@ -1,6 +1,6 @@ use buffer::CapacityError; use common::pretty; -use error::Error; +use crate::error::Error; use packer::Packer; use packer::Unpacker; use packer::Warning; @@ -333,7 +333,7 @@ pub struct Input { pub ack_snapshot: i32, pub intended_tick: i32, pub input_size: i32, - pub input: ::snap_obj::PlayerInput, + pub input: crate::snap_obj::PlayerInput, } #[derive(Clone, Copy)] @@ -635,7 +635,7 @@ impl Input { ack_snapshot: _p.read_int(warn)?, intended_tick: _p.read_int(warn)?, input_size: _p.read_int(warn)?, - input: ::snap_obj::PlayerInput::decode_msg(warn, _p)?, + input: crate::snap_obj::PlayerInput::decode_msg(warn, _p)?, }); _p.finish(warn); result diff --git a/gamenet/teeworlds-0.5/src/snap_obj.rs b/gamenet/teeworlds-0.5/src/snap_obj.rs index 206f1961..b6e7fe86 100644 --- a/gamenet/teeworlds-0.5/src/snap_obj.rs +++ b/gamenet/teeworlds-0.5/src/snap_obj.rs @@ -1,7 +1,7 @@ use buffer::CapacityError; use common::slice; -use enums; -use error::Error; +use crate::enums; +use crate::error::Error; use packer::ExcessData; use packer::IntUnpacker; use packer::Packer; @@ -287,7 +287,7 @@ pub struct Projectile { pub vel_x: i32, pub vel_y: i32, pub type_: enums::Weapon, - pub start_tick: ::snap_obj::Tick, + pub start_tick: crate::snap_obj::Tick, } #[repr(C)] @@ -297,7 +297,7 @@ pub struct Laser { pub y: i32, pub from_x: i32, pub from_y: i32, - pub start_tick: ::snap_obj::Tick, + pub start_tick: crate::snap_obj::Tick, } #[repr(C)] @@ -322,7 +322,7 @@ pub struct Flag { #[derive(Clone, Copy)] pub struct Game { pub flags: i32, - pub round_start_tick: ::snap_obj::Tick, + pub round_start_tick: crate::snap_obj::Tick, pub game_over: i32, pub sudden_death: i32, pub paused: i32, @@ -348,7 +348,7 @@ pub struct CharacterCore { pub jumped: i32, pub hooked_player: i32, pub hook_state: i32, - pub hook_tick: ::snap_obj::Tick, + pub hook_tick: crate::snap_obj::Tick, pub hook_x: i32, pub hook_y: i32, pub hook_dx: i32, @@ -541,7 +541,7 @@ impl Projectile { vel_x: _p.read_int()?, vel_y: _p.read_int()?, type_: enums::Weapon::from_i32(_p.read_int()?)?, - start_tick: ::snap_obj::Tick(_p.read_int()?), + start_tick: crate::snap_obj::Tick(_p.read_int()?), }) } pub fn encode(&self) -> &[i32] { @@ -556,7 +556,7 @@ impl Projectile { vel_x: _p.read_int(warn)?, vel_y: _p.read_int(warn)?, type_: enums::Weapon::from_i32(_p.read_int(warn)?)?, - start_tick: ::snap_obj::Tick(_p.read_int(warn)?), + start_tick: crate::snap_obj::Tick(_p.read_int(warn)?), }); _p.finish(warn); result @@ -595,7 +595,7 @@ impl Laser { y: _p.read_int()?, from_x: _p.read_int()?, from_y: _p.read_int()?, - start_tick: ::snap_obj::Tick(_p.read_int()?), + start_tick: crate::snap_obj::Tick(_p.read_int()?), }) } pub fn encode(&self) -> &[i32] { @@ -692,7 +692,7 @@ impl Game { pub fn decode_inner(_p: &mut IntUnpacker) -> Result { Ok(Game { flags: in_range(_p.read_int()?, 0, 256)?, - round_start_tick: ::snap_obj::Tick(_p.read_int()?), + round_start_tick: crate::snap_obj::Tick(_p.read_int()?), game_over: in_range(_p.read_int()?, 0, 1)?, sudden_death: in_range(_p.read_int()?, 0, 1)?, paused: in_range(_p.read_int()?, 0, 1)?, @@ -758,7 +758,7 @@ impl CharacterCore { jumped: in_range(_p.read_int()?, 0, 3)?, hooked_player: in_range(_p.read_int()?, -1, 15)?, hook_state: in_range(_p.read_int()?, -1, 5)?, - hook_tick: ::snap_obj::Tick(_p.read_int()?), + hook_tick: crate::snap_obj::Tick(_p.read_int()?), hook_x: _p.read_int()?, hook_y: _p.read_int()?, hook_dx: _p.read_int()?, diff --git a/gamenet/teeworlds-0.6/Cargo.toml b/gamenet/teeworlds-0.6/Cargo.toml index d581007b..f3170016 100644 --- a/gamenet/teeworlds-0.6/Cargo.toml +++ b/gamenet/teeworlds-0.6/Cargo.toml @@ -3,6 +3,7 @@ name = "gamenet_teeworlds_0_6" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = "0.5.2" diff --git a/gamenet/teeworlds-0.6/src/lib.rs b/gamenet/teeworlds-0.6/src/lib.rs index 34ebc8cb..34cc3cea 100644 --- a/gamenet/teeworlds-0.6/src/lib.rs +++ b/gamenet/teeworlds-0.6/src/lib.rs @@ -1,11 +1,3 @@ -extern crate arrayvec; -extern crate buffer; -extern crate common; -extern crate gamenet_common; -extern crate packer; -extern crate uuid; -extern crate warn; - #[rustfmt::skip] pub mod enums; #[rustfmt::skip] @@ -13,6 +5,6 @@ pub mod msg; #[rustfmt::skip] pub mod snap_obj; +pub use self::snap_obj::SnapObj; pub use gamenet_common::error; pub use gamenet_common::error::Error; -pub use snap_obj::SnapObj; diff --git a/gamenet/teeworlds-0.6/src/msg/connless.rs b/gamenet/teeworlds-0.6/src/msg/connless.rs index a89b0c59..d4e92cc3 100644 --- a/gamenet/teeworlds-0.6/src/msg/connless.rs +++ b/gamenet/teeworlds-0.6/src/msg/connless.rs @@ -1,6 +1,6 @@ use buffer::CapacityError; use common::pretty; -use error::Error; +use crate::error::Error; use gamenet_common::msg::AddrPackedSliceExt; use gamenet_common::msg::int_from_string; use gamenet_common::msg::string_from_int; diff --git a/gamenet/teeworlds-0.6/src/msg/game.rs b/gamenet/teeworlds-0.6/src/msg/game.rs index 5ea50c27..a1dd0937 100644 --- a/gamenet/teeworlds-0.6/src/msg/game.rs +++ b/gamenet/teeworlds-0.6/src/msg/game.rs @@ -1,7 +1,7 @@ use buffer::CapacityError; use common::pretty; -use enums; -use error::Error; +use crate::enums; +use crate::error::Error; use gamenet_common::debug::DebugSlice; use packer::Packer; use packer::Unpacker; @@ -434,7 +434,7 @@ pub struct SvTuneParams { #[derive(Clone, Copy)] pub struct SvExtraProjectile { - pub projectile: ::snap_obj::Projectile, + pub projectile: crate::snap_obj::Projectile, } #[derive(Clone, Copy)] @@ -824,7 +824,7 @@ impl fmt::Debug for SvTuneParams { impl SvExtraProjectile { pub fn decode>(warn: &mut W, _p: &mut Unpacker) -> Result { let result = Ok(SvExtraProjectile { - projectile: ::snap_obj::Projectile::decode_msg(warn, _p)?, + projectile: crate::snap_obj::Projectile::decode_msg(warn, _p)?, }); _p.finish(warn); result diff --git a/gamenet/teeworlds-0.6/src/msg/system.rs b/gamenet/teeworlds-0.6/src/msg/system.rs index f693ac04..74ea24d1 100644 --- a/gamenet/teeworlds-0.6/src/msg/system.rs +++ b/gamenet/teeworlds-0.6/src/msg/system.rs @@ -1,6 +1,6 @@ use buffer::CapacityError; use common::pretty; -use error::Error; +use crate::error::Error; use packer::Packer; use packer::Unpacker; use packer::Warning; @@ -373,7 +373,7 @@ pub struct Input { pub ack_snapshot: i32, pub intended_tick: i32, pub input_size: i32, - pub input: ::snap_obj::PlayerInput, + pub input: crate::snap_obj::PlayerInput, } #[derive(Clone, Copy)] @@ -711,7 +711,7 @@ impl Input { ack_snapshot: _p.read_int(warn)?, intended_tick: _p.read_int(warn)?, input_size: _p.read_int(warn)?, - input: ::snap_obj::PlayerInput::decode_msg(warn, _p)?, + input: crate::snap_obj::PlayerInput::decode_msg(warn, _p)?, }); _p.finish(warn); result diff --git a/gamenet/teeworlds-0.6/src/snap_obj.rs b/gamenet/teeworlds-0.6/src/snap_obj.rs index f1c19ce4..02e220c0 100644 --- a/gamenet/teeworlds-0.6/src/snap_obj.rs +++ b/gamenet/teeworlds-0.6/src/snap_obj.rs @@ -1,7 +1,7 @@ use buffer::CapacityError; use common::slice; -use enums; -use error::Error; +use crate::enums; +use crate::error::Error; use packer::ExcessData; use packer::IntUnpacker; use packer::Packer; @@ -320,7 +320,7 @@ pub struct Projectile { pub vel_x: i32, pub vel_y: i32, pub type_: enums::Weapon, - pub start_tick: ::snap_obj::Tick, + pub start_tick: crate::snap_obj::Tick, } #[repr(C)] @@ -330,7 +330,7 @@ pub struct Laser { pub y: i32, pub from_x: i32, pub from_y: i32, - pub start_tick: ::snap_obj::Tick, + pub start_tick: crate::snap_obj::Tick, } #[repr(C)] @@ -355,7 +355,7 @@ pub struct Flag { pub struct GameInfo { pub game_flags: i32, pub game_state_flags: i32, - pub round_start_tick: ::snap_obj::Tick, + pub round_start_tick: crate::snap_obj::Tick, pub warmup_timer: i32, pub score_limit: i32, pub time_limit: i32, @@ -385,7 +385,7 @@ pub struct CharacterCore { pub jumped: i32, pub hooked_player: i32, pub hook_state: i32, - pub hook_tick: ::snap_obj::Tick, + pub hook_tick: crate::snap_obj::Tick, pub hook_x: i32, pub hook_y: i32, pub hook_dx: i32, @@ -585,7 +585,7 @@ impl Projectile { vel_x: _p.read_int()?, vel_y: _p.read_int()?, type_: enums::Weapon::from_i32(_p.read_int()?)?, - start_tick: ::snap_obj::Tick(_p.read_int()?), + start_tick: crate::snap_obj::Tick(_p.read_int()?), }) } pub fn encode(&self) -> &[i32] { @@ -600,7 +600,7 @@ impl Projectile { vel_x: _p.read_int(warn)?, vel_y: _p.read_int(warn)?, type_: enums::Weapon::from_i32(_p.read_int(warn)?)?, - start_tick: ::snap_obj::Tick(_p.read_int(warn)?), + start_tick: crate::snap_obj::Tick(_p.read_int(warn)?), }); _p.finish(warn); result @@ -639,7 +639,7 @@ impl Laser { y: _p.read_int()?, from_x: _p.read_int()?, from_y: _p.read_int()?, - start_tick: ::snap_obj::Tick(_p.read_int()?), + start_tick: crate::snap_obj::Tick(_p.read_int()?), }) } pub fn encode(&self) -> &[i32] { @@ -730,7 +730,7 @@ impl GameInfo { Ok(GameInfo { game_flags: in_range(_p.read_int()?, 0, 256)?, game_state_flags: in_range(_p.read_int()?, 0, 256)?, - round_start_tick: ::snap_obj::Tick(_p.read_int()?), + round_start_tick: crate::snap_obj::Tick(_p.read_int()?), warmup_timer: positive(_p.read_int()?)?, score_limit: positive(_p.read_int()?)?, time_limit: positive(_p.read_int()?)?, @@ -820,7 +820,7 @@ impl CharacterCore { jumped: in_range(_p.read_int()?, 0, 3)?, hooked_player: in_range(_p.read_int()?, -1, 15)?, hook_state: in_range(_p.read_int()?, -1, 5)?, - hook_tick: ::snap_obj::Tick(_p.read_int()?), + hook_tick: crate::snap_obj::Tick(_p.read_int()?), hook_x: _p.read_int()?, hook_y: _p.read_int()?, hook_dx: _p.read_int()?, diff --git a/gamenet/teeworlds-0.7/Cargo.toml b/gamenet/teeworlds-0.7/Cargo.toml index 4e1103f6..5520de14 100644 --- a/gamenet/teeworlds-0.7/Cargo.toml +++ b/gamenet/teeworlds-0.7/Cargo.toml @@ -3,6 +3,7 @@ name = "gamenet_teeworlds_0_7" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = "0.5.2" diff --git a/gamenet/teeworlds-0.7/src/lib.rs b/gamenet/teeworlds-0.7/src/lib.rs index 34ebc8cb..34cc3cea 100644 --- a/gamenet/teeworlds-0.7/src/lib.rs +++ b/gamenet/teeworlds-0.7/src/lib.rs @@ -1,11 +1,3 @@ -extern crate arrayvec; -extern crate buffer; -extern crate common; -extern crate gamenet_common; -extern crate packer; -extern crate uuid; -extern crate warn; - #[rustfmt::skip] pub mod enums; #[rustfmt::skip] @@ -13,6 +5,6 @@ pub mod msg; #[rustfmt::skip] pub mod snap_obj; +pub use self::snap_obj::SnapObj; pub use gamenet_common::error; pub use gamenet_common::error::Error; -pub use snap_obj::SnapObj; diff --git a/gamenet/teeworlds-0.7/src/msg/connless.rs b/gamenet/teeworlds-0.7/src/msg/connless.rs index 21bffc2b..bd5a3a2c 100644 --- a/gamenet/teeworlds-0.7/src/msg/connless.rs +++ b/gamenet/teeworlds-0.7/src/msg/connless.rs @@ -1,6 +1,6 @@ use buffer::CapacityError; use common::pretty; -use error::Error; +use crate::error::Error; use gamenet_common::msg::AddrPackedSliceExt; use gamenet_common::msg::string_from_int; use packer::Packer; diff --git a/gamenet/teeworlds-0.7/src/msg/game.rs b/gamenet/teeworlds-0.7/src/msg/game.rs index a240f054..ed4a617b 100644 --- a/gamenet/teeworlds-0.7/src/msg/game.rs +++ b/gamenet/teeworlds-0.7/src/msg/game.rs @@ -1,7 +1,7 @@ use buffer::CapacityError; use common::pretty; -use enums; -use error::Error; +use crate::enums; +use crate::error::Error; use gamenet_common::debug::DebugSlice; use packer::Packer; use packer::Unpacker; @@ -558,7 +558,7 @@ pub struct SvTeam { pub client_id: i32, pub team: enums::Team, pub silent: bool, - pub cooldown_tick: ::snap_obj::Tick, + pub cooldown_tick: crate::snap_obj::Tick, } #[derive(Clone, Copy)] @@ -607,7 +607,7 @@ pub struct SvTuneParams { #[derive(Clone, Copy)] pub struct SvExtraProjectile { - pub projectile: ::snap_obj::Projectile, + pub projectile: crate::snap_obj::Projectile, } #[derive(Clone, Copy)] @@ -894,7 +894,7 @@ impl SvTeam { client_id: in_range(_p.read_int(warn)?, -1, 63)?, team: enums::Team::from_i32(_p.read_int(warn)?)?, silent: to_bool(_p.read_int(warn)?)?, - cooldown_tick: ::snap_obj::Tick(_p.read_int(warn)?), + cooldown_tick: crate::snap_obj::Tick(_p.read_int(warn)?), }); _p.finish(warn); result @@ -1069,7 +1069,7 @@ impl fmt::Debug for SvTuneParams { impl SvExtraProjectile { pub fn decode>(warn: &mut W, _p: &mut Unpacker) -> Result { let result = Ok(SvExtraProjectile { - projectile: ::snap_obj::Projectile::decode_msg(warn, _p)?, + projectile: crate::snap_obj::Projectile::decode_msg(warn, _p)?, }); _p.finish(warn); result diff --git a/gamenet/teeworlds-0.7/src/msg/system.rs b/gamenet/teeworlds-0.7/src/msg/system.rs index f0ca5aaa..6f4290ce 100644 --- a/gamenet/teeworlds-0.7/src/msg/system.rs +++ b/gamenet/teeworlds-0.7/src/msg/system.rs @@ -1,7 +1,7 @@ use buffer::CapacityError; use common::digest::Sha256; use common::pretty; -use error::Error; +use crate::error::Error; use packer::Packer; use packer::Unpacker; use packer::Warning; @@ -440,7 +440,7 @@ pub struct Input { pub ack_snapshot: i32, pub intended_tick: i32, pub input_size: i32, - pub input: ::snap_obj::PlayerInput, + pub input: crate::snap_obj::PlayerInput, } #[derive(Clone, Copy)] @@ -853,7 +853,7 @@ impl Input { ack_snapshot: _p.read_int(warn)?, intended_tick: _p.read_int(warn)?, input_size: _p.read_int(warn)?, - input: ::snap_obj::PlayerInput::decode_msg(warn, _p)?, + input: crate::snap_obj::PlayerInput::decode_msg(warn, _p)?, }); _p.finish(warn); result diff --git a/gamenet/teeworlds-0.7/src/snap_obj.rs b/gamenet/teeworlds-0.7/src/snap_obj.rs index 1a1baf34..3d1f21c5 100644 --- a/gamenet/teeworlds-0.7/src/snap_obj.rs +++ b/gamenet/teeworlds-0.7/src/snap_obj.rs @@ -1,7 +1,7 @@ use buffer::CapacityError; use common::slice; -use enums; -use error::Error; +use crate::enums; +use crate::error::Error; use packer::ExcessData; use packer::IntUnpacker; use packer::Packer; @@ -388,7 +388,7 @@ pub struct Projectile { pub vel_x: i32, pub vel_y: i32, pub type_: enums::Weapon, - pub start_tick: ::snap_obj::Tick, + pub start_tick: crate::snap_obj::Tick, } #[repr(C)] @@ -398,7 +398,7 @@ pub struct Laser { pub y: i32, pub from_x: i32, pub from_y: i32, - pub start_tick: ::snap_obj::Tick, + pub start_tick: crate::snap_obj::Tick, } #[repr(C)] @@ -420,9 +420,9 @@ pub struct Flag { #[repr(C)] #[derive(Clone, Copy)] pub struct GameData { - pub game_start_tick: ::snap_obj::Tick, + pub game_start_tick: crate::snap_obj::Tick, pub game_state_flags: i32, - pub game_state_end_tick: ::snap_obj::Tick, + pub game_state_end_tick: crate::snap_obj::Tick, } #[repr(C)] @@ -437,14 +437,14 @@ pub struct GameDataTeam { pub struct GameDataFlag { pub flag_carrier_red: i32, pub flag_carrier_blue: i32, - pub flag_drop_tick_red: ::snap_obj::Tick, - pub flag_drop_tick_blue: ::snap_obj::Tick, + pub flag_drop_tick_red: crate::snap_obj::Tick, + pub flag_drop_tick_blue: crate::snap_obj::Tick, } #[repr(C)] #[derive(Clone, Copy)] pub struct CharacterCore { - pub tick: ::snap_obj::Tick, + pub tick: crate::snap_obj::Tick, pub x: i32, pub y: i32, pub vel_x: i32, @@ -454,7 +454,7 @@ pub struct CharacterCore { pub jumped: i32, pub hooked_player: i32, pub hook_state: i32, - pub hook_tick: ::snap_obj::Tick, + pub hook_tick: crate::snap_obj::Tick, pub hook_x: i32, pub hook_y: i32, pub hook_dx: i32, @@ -470,7 +470,7 @@ pub struct Character { pub ammo_count: i32, pub weapon: enums::Weapon, pub emote: enums::Emote, - pub attack_tick: ::snap_obj::Tick, + pub attack_tick: crate::snap_obj::Tick, pub triggered_events: i32, } @@ -573,7 +573,7 @@ pub struct Damage { #[repr(C)] #[derive(Clone, Copy)] pub struct PlayerInfoRace { - pub race_start_tick: ::snap_obj::Tick, + pub race_start_tick: crate::snap_obj::Tick, } #[repr(C)] @@ -685,7 +685,7 @@ impl Projectile { vel_x: _p.read_int()?, vel_y: _p.read_int()?, type_: enums::Weapon::from_i32(_p.read_int()?)?, - start_tick: ::snap_obj::Tick(_p.read_int()?), + start_tick: crate::snap_obj::Tick(_p.read_int()?), }) } pub fn encode(&self) -> &[i32] { @@ -700,7 +700,7 @@ impl Projectile { vel_x: _p.read_int(warn)?, vel_y: _p.read_int(warn)?, type_: enums::Weapon::from_i32(_p.read_int(warn)?)?, - start_tick: ::snap_obj::Tick(_p.read_int(warn)?), + start_tick: crate::snap_obj::Tick(_p.read_int(warn)?), }); _p.finish(warn); result @@ -739,7 +739,7 @@ impl Laser { y: _p.read_int()?, from_x: _p.read_int()?, from_y: _p.read_int()?, - start_tick: ::snap_obj::Tick(_p.read_int()?), + start_tick: crate::snap_obj::Tick(_p.read_int()?), }) } pub fn encode(&self) -> &[i32] { @@ -819,9 +819,9 @@ impl GameData { } pub fn decode_inner(_p: &mut IntUnpacker) -> Result { Ok(GameData { - game_start_tick: ::snap_obj::Tick(_p.read_int()?), + game_start_tick: crate::snap_obj::Tick(_p.read_int()?), game_state_flags: _p.read_int()?, - game_state_end_tick: ::snap_obj::Tick(_p.read_int()?), + game_state_end_tick: crate::snap_obj::Tick(_p.read_int()?), }) } pub fn encode(&self) -> &[i32] { @@ -874,8 +874,8 @@ impl GameDataFlag { Ok(GameDataFlag { flag_carrier_red: in_range(_p.read_int()?, -3, 63)?, flag_carrier_blue: in_range(_p.read_int()?, -3, 63)?, - flag_drop_tick_red: ::snap_obj::Tick(_p.read_int()?), - flag_drop_tick_blue: ::snap_obj::Tick(_p.read_int()?), + flag_drop_tick_red: crate::snap_obj::Tick(_p.read_int()?), + flag_drop_tick_blue: crate::snap_obj::Tick(_p.read_int()?), }) } pub fn encode(&self) -> &[i32] { @@ -914,7 +914,7 @@ impl CharacterCore { } pub fn decode_inner(_p: &mut IntUnpacker) -> Result { Ok(CharacterCore { - tick: ::snap_obj::Tick(_p.read_int()?), + tick: crate::snap_obj::Tick(_p.read_int()?), x: _p.read_int()?, y: _p.read_int()?, vel_x: _p.read_int()?, @@ -924,7 +924,7 @@ impl CharacterCore { jumped: in_range(_p.read_int()?, 0, 3)?, hooked_player: in_range(_p.read_int()?, -1, 63)?, hook_state: in_range(_p.read_int()?, -1, 5)?, - hook_tick: ::snap_obj::Tick(_p.read_int()?), + hook_tick: crate::snap_obj::Tick(_p.read_int()?), hook_x: _p.read_int()?, hook_y: _p.read_int()?, hook_dx: _p.read_int()?, @@ -968,7 +968,7 @@ impl Character { ammo_count: _p.read_int()?, weapon: enums::Weapon::from_i32(_p.read_int()?)?, emote: enums::Emote::from_i32(_p.read_int()?)?, - attack_tick: ::snap_obj::Tick(_p.read_int()?), + attack_tick: crate::snap_obj::Tick(_p.read_int()?), triggered_events: _p.read_int()?, }) } @@ -1439,7 +1439,7 @@ impl PlayerInfoRace { } pub fn decode_inner(_p: &mut IntUnpacker) -> Result { Ok(PlayerInfoRace { - race_start_tick: ::snap_obj::Tick(_p.read_int()?), + race_start_tick: crate::snap_obj::Tick(_p.read_int()?), }) } pub fn encode(&self) -> &[i32] { diff --git a/huffman/Cargo.toml b/huffman/Cargo.toml index 1664e762..1e0d6d96 100644 --- a/huffman/Cargo.toml +++ b/huffman/Cargo.toml @@ -3,6 +3,7 @@ name = "huffman" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = "0.5.2" diff --git a/huffman/benches/compression.rs b/huffman/benches/compression.rs index 31ee523f..2ef61488 100644 --- a/huffman/benches/compression.rs +++ b/huffman/benches/compression.rs @@ -1,11 +1,5 @@ -#[macro_use] -extern crate bencher; -extern crate buffer; -extern crate common; -extern crate huffman; -extern crate huffman_reference; -extern crate itertools; - +use bencher::benchmark_group; +use bencher::benchmark_main; use bencher::black_box; use bencher::Bencher; use common::num::Cast; diff --git a/huffman/reference/Cargo.toml b/huffman/reference/Cargo.toml index cd2273ea..5732481c 100644 --- a/huffman/reference/Cargo.toml +++ b/huffman/reference/Cargo.toml @@ -2,6 +2,7 @@ name = "huffman-reference" version = "0.0.1" authors = ["heinrich5991 "] +edition = "2021" [dependencies] buffer = "0.1.9" diff --git a/huffman/reference/src/lib.rs b/huffman/reference/src/lib.rs index 1d6eb96a..f5fe3fdd 100644 --- a/huffman/reference/src/lib.rs +++ b/huffman/reference/src/lib.rs @@ -1,8 +1,4 @@ -extern crate buffer; -extern crate common; -extern crate huffman; extern crate huffman_reference_sys as sys; -extern crate libc; use buffer::with_buffer; use buffer::Buffer; diff --git a/huffman/reference/sys/Cargo.toml b/huffman/reference/sys/Cargo.toml index a4aac4c0..f3e68ec4 100644 --- a/huffman/reference/sys/Cargo.toml +++ b/huffman/reference/sys/Cargo.toml @@ -2,7 +2,7 @@ name = "huffman-reference-sys" version = "0.0.1" authors = ["heinrich5991 "] -build = "build.rs" +edition = "2021" [build-dependencies] cc = "1.0.3" diff --git a/huffman/reference/sys/build.rs b/huffman/reference/sys/build.rs index 0efe45e7..ee972df9 100644 --- a/huffman/reference/sys/build.rs +++ b/huffman/reference/sys/build.rs @@ -1,5 +1,3 @@ -extern crate cc; - fn main() { cc::Build::new() .include("src/include") diff --git a/huffman/reference/sys/src/lib.rs b/huffman/reference/sys/src/lib.rs index a05c7a30..74f6dd2d 100644 --- a/huffman/reference/sys/src/lib.rs +++ b/huffman/reference/sys/src/lib.rs @@ -1,5 +1,3 @@ -extern crate libc; - #[link(name = "huffman")] extern "C" { pub fn huffman_size() -> libc::size_t; diff --git a/huffman/src/instances/teeworlds.rs b/huffman/src/instances/teeworlds.rs index 4b301079..e02c9f88 100644 --- a/huffman/src/instances/teeworlds.rs +++ b/huffman/src/instances/teeworlds.rs @@ -1,5 +1,5 @@ -use Huffman; -use Node; +use crate::Huffman; +use crate::Node; pub const INSTANCE: Huffman = Huffman { nodes: [ Node { children: [256, 1] }, Node { children: [1024, 8] }, diff --git a/huffman/src/lib.rs b/huffman/src/lib.rs index 4c96daef..0dde1954 100644 --- a/huffman/src/lib.rs +++ b/huffman/src/lib.rs @@ -1,12 +1,3 @@ -#[cfg(test)] -#[macro_use] -extern crate quickcheck; - -extern crate arrayvec; -extern crate buffer; -extern crate common; -extern crate itertools; - use arrayvec::ArrayVec; use buffer::with_buffer; use buffer::Buffer; @@ -526,6 +517,7 @@ impl fmt::Display for SymbolRepr { mod test { use super::Node; use super::SymbolRepr; + use quickcheck::quickcheck; quickcheck! { fn roundtrip_node(v: (u16, u16)) -> bool { diff --git a/huffman/src/main.rs b/huffman/src/main.rs index aed794e0..85b88178 100644 --- a/huffman/src/main.rs +++ b/huffman/src/main.rs @@ -1,5 +1,3 @@ -extern crate huffman; - use huffman::Huffman; use std::fs::File; use std::io::BufRead; diff --git a/huffman/tests/correctness.rs b/huffman/tests/correctness.rs index 621e96ab..13e442fb 100644 --- a/huffman/tests/correctness.rs +++ b/huffman/tests/correctness.rs @@ -1,7 +1,3 @@ -extern crate common; -extern crate huffman; -extern crate itertools; - use huffman::Huffman; use itertools::Itertools; use std::fs::File; diff --git a/logger/Cargo.toml b/logger/Cargo.toml index 1c2ac886..d33db480 100644 --- a/logger/Cargo.toml +++ b/logger/Cargo.toml @@ -3,6 +3,7 @@ name = "logger" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] env_logger = "0.3.0" diff --git a/logger/src/lib.rs b/logger/src/lib.rs index 159ecabd..fe627811 100644 --- a/logger/src/lib.rs +++ b/logger/src/lib.rs @@ -1,5 +1,3 @@ -extern crate env_logger; - pub fn init() { env_logger::init().unwrap(); } diff --git a/map/Cargo.toml b/map/Cargo.toml index ff75a13c..3051af09 100644 --- a/map/Cargo.toml +++ b/map/Cargo.toml @@ -3,6 +3,7 @@ name = "map" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] common = { path = "../common/" } diff --git a/map/src/format.rs b/map/src/format.rs index 394e93e2..6551c4b7 100644 --- a/map/src/format.rs +++ b/map/src/format.rs @@ -1,4 +1,4 @@ -use common; +use common::unwrap_or_return; use datafile::OnlyI32; use std::fmt; use std::mem; diff --git a/map/src/generate_format.py b/map/src/generate_format.py index 01a5f919..61f168cc 100644 --- a/map/src/generate_format.py +++ b/map/src/generate_format.py @@ -50,7 +50,7 @@ ] header = """\ -use common; +use common::unwrap_or_return; use datafile::OnlyI32; use std::fmt; use std::mem; diff --git a/map/src/lib.rs b/map/src/lib.rs index 36cd3616..5636a623 100644 --- a/map/src/lib.rs +++ b/map/src/lib.rs @@ -1,11 +1,5 @@ -#[macro_use] -extern crate common; -extern crate datafile; -extern crate ndarray; -extern crate zerocopy; - -pub use reader::Error; -pub use reader::Reader; +pub use self::reader::Error; +pub use self::reader::Reader; #[rustfmt::skip] pub mod format; diff --git a/map/src/reader.rs b/map/src/reader.rs index 79df6462..507d6189 100644 --- a/map/src/reader.rs +++ b/map/src/reader.rs @@ -1,4 +1,9 @@ +use crate::format; +use crate::format::Error as MapError; +use crate::format::MapItem; +use crate::format::MapItemExt; use common::num::Cast; +use common::unwrap_or_return; use common::vec; use datafile as df; use ndarray::Array2; @@ -7,11 +12,6 @@ use std::mem; use std::ops; use std::path::Path; -use format; -use format::Error as MapError; -use format::MapItem; -use format::MapItemExt; - #[derive(Debug)] pub enum Error { Map(MapError), diff --git a/net/Cargo.toml b/net/Cargo.toml index ba89f5c7..39a2be2d 100644 --- a/net/Cargo.toml +++ b/net/Cargo.toml @@ -3,6 +3,7 @@ name = "net" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = "0.5.2" diff --git a/net/src/collections/peer_map.rs b/net/src/collections/peer_map.rs index cca56be3..33176cc4 100644 --- a/net/src/collections/peer_map.rs +++ b/net/src/collections/peer_map.rs @@ -1,6 +1,5 @@ -use linear_map; +use crate::net::PeerId; use linear_map::LinearMap; -use net::PeerId; use std::fmt; use std::iter::FromIterator; use std::ops; diff --git a/net/src/collections/peer_set.rs b/net/src/collections/peer_set.rs index 0ae78e26..0712ff8c 100644 --- a/net/src/collections/peer_set.rs +++ b/net/src/collections/peer_set.rs @@ -1,6 +1,6 @@ use super::peer_map; use super::PeerMap; -use net::PeerId; +use crate::net::PeerId; use std::fmt; use std::iter::FromIterator; diff --git a/net/src/connection.rs b/net/src/connection.rs index 5ec936a4..275bb913 100644 --- a/net/src/connection.rs +++ b/net/src/connection.rs @@ -1,24 +1,25 @@ +use crate::protocol; +use crate::protocol::ChunksIter; +use crate::protocol::ConnectedPacket; +use crate::protocol::ConnectedPacketType; +use crate::protocol::ControlPacket; +use crate::protocol::Packet; +use crate::protocol::Token; +use crate::protocol::MAX_PACKETSIZE; +use crate::protocol::MAX_PAYLOAD; +use crate::protocol::TOKEN_NONE; +use crate::Timeout; +use crate::Timestamp; use arrayvec::ArrayVec; use buffer::with_buffer; use buffer::Buffer; use buffer::BufferRef; -use protocol; -use protocol::ChunksIter; -use protocol::ConnectedPacket; -use protocol::ConnectedPacketType; -use protocol::ControlPacket; -use protocol::Packet; -use protocol::Token; -use protocol::MAX_PACKETSIZE; -use protocol::MAX_PAYLOAD; -use protocol::TOKEN_NONE; +use matches::assert_matches; use std::cmp; use std::collections::VecDeque; use std::iter; use std::time::Duration; use warn::Warn; -use Timeout; -use Timestamp; // TODO: Implement receive timeout. // TODO: Don't allow for unbounded backlog of vital messages. @@ -807,14 +808,14 @@ mod test { use super::ReceiveChunk; use super::Sequence; use super::SequenceOrdering; + use crate::protocol; + use crate::Timestamp; use hexdump::hexdump; use itertools::Itertools; - use protocol; use std::collections::VecDeque; use void::ResultVoidExt; use void::Void; use warn::Panic; - use Timestamp; #[test] fn sequence_compare() { diff --git a/net/src/lib.rs b/net/src/lib.rs index 5235d687..bfef8cee 100644 --- a/net/src/lib.rs +++ b/net/src/lib.rs @@ -1,26 +1,3 @@ -#[cfg(test)] -extern crate hexdump; -#[cfg(test)] -extern crate itertools; -#[cfg(test)] -#[macro_use] -extern crate quickcheck; - -extern crate arrayvec; -extern crate assert_matches; -extern crate buffer; -#[macro_use] -extern crate common; -extern crate huffman; -extern crate linear_map; -#[macro_use] -extern crate matches; -extern crate optional; -extern crate void; -extern crate warn; -extern crate zerocopy; -extern crate zerocopy_derive; - pub mod collections; pub mod connection; pub mod net; @@ -28,7 +5,7 @@ pub mod protocol; pub mod protocol7; pub mod time; -pub use connection::Connection; -pub use net::Net; -pub use time::Timeout; -pub use time::Timestamp; +pub use self::connection::Connection; +pub use self::net::Net; +pub use self::time::Timeout; +pub use self::time::Timestamp; diff --git a/net/src/net.rs b/net/src/net.rs index 5762a34d..270f1448 100644 --- a/net/src/net.rs +++ b/net/src/net.rs @@ -1,27 +1,27 @@ +use crate::collections::peer_map; +use crate::collections::PeerMap; +use crate::connection; +use crate::connection::ReceiveChunk; +use crate::protocol; +use crate::protocol::ConnectedPacket; +use crate::protocol::ConnectedPacketType; +use crate::protocol::ControlPacket; +use crate::protocol::Packet; +use crate::Connection; +use crate::Timeout; +use crate::Timestamp; use arrayvec::ArrayVec; use buffer::with_buffer; use buffer::Buffer; use buffer::BufferRef; -use collections::peer_map; -use collections::PeerMap; -use connection; -use connection::ReceiveChunk; -use protocol; -use protocol::ConnectedPacket; -use protocol::ConnectedPacketType; -use protocol::ControlPacket; -use protocol::Packet; use std::fmt; use std::hash::Hash; use std::iter; use std::ops; use warn::Panic; use warn::Warn; -use Connection; -use Timeout; -use Timestamp; -pub use connection::Error; +pub use crate::connection::Error; pub trait Callback { type Error; @@ -577,13 +577,13 @@ mod test { use super::Callback; use super::ChunkOrEvent; use super::Net; + use crate::protocol; + use crate::Timestamp; use itertools::Itertools; - use protocol; use std::collections::VecDeque; use void::ResultVoidExt; use void::Void; use warn::Panic; - use Timestamp; #[test] fn establish_connection() { diff --git a/net/src/protocol.rs b/net/src/protocol.rs index c923f703..afd9a2ad 100644 --- a/net/src/protocol.rs +++ b/net/src/protocol.rs @@ -1,12 +1,12 @@ use arrayvec::ArrayVec; -use buffer; use buffer::with_buffer; use buffer::Buffer; use buffer::BufferRef; +use common::boilerplate_packed; use common::bytes::FromBytesExt as _; use common::num::Cast; use common::pretty; -use huffman; +use common::unwrap_or_return; use huffman::instances::TEEWORLDS as HUFFMAN; use std::cmp; use std::fmt; @@ -917,6 +917,7 @@ mod test { use super::PACKET_FLAGS_BITS; use super::SEQUENCE_BITS; use common::bytes::FromBytesExt; + use quickcheck::quickcheck; use warn::Ignore; use warn::Panic; use warn::Warn; @@ -1038,6 +1039,7 @@ mod test { #[cfg(test)] #[rustfmt::skip] mod test_no_token { + use quickcheck::quickcheck; use super::MAX_PACKETSIZE; use super::Packet; use super::PacketReadError::*; @@ -1103,6 +1105,7 @@ mod test_no_token { #[cfg(test)] #[rustfmt::skip] mod test_token { + use quickcheck::quickcheck; use super::MAX_PACKETSIZE; use super::Packet; use super::PacketReadError::*; diff --git a/net/src/protocol7.rs b/net/src/protocol7.rs index 4b79e5b1..9f4875bb 100644 --- a/net/src/protocol7.rs +++ b/net/src/protocol7.rs @@ -1,10 +1,11 @@ use buffer::with_buffer; use buffer::Buffer; use buffer::BufferRef; +use common::boilerplate_packed; use common::bytes::FromBytesExt as _; use common::num::Cast; use common::pretty; -use huffman; +use common::unwrap_or_return; use huffman::instances::TEEWORLDS as HUFFMAN; use std::cmp; use std::fmt; @@ -693,6 +694,7 @@ boilerplate_packed!( #[rustfmt::skip] mod test { use common::bytes::FromBytesExt as _; + use quickcheck::quickcheck; use super::CHUNK_FLAGS_BITS; use super::CHUNK_SIZE_BITS; use super::ChunkHeader; diff --git a/net/src/time.rs b/net/src/time.rs index bf6db57d..ec77a690 100644 --- a/net/src/time.rs +++ b/net/src/time.rs @@ -1,5 +1,4 @@ use common::num::Cast; -use optional; use optional::Optioned; use std::cmp; use std::ops; diff --git a/packer/Cargo.toml b/packer/Cargo.toml index 580ff9c0..0ef492a5 100644 --- a/packer/Cargo.toml +++ b/packer/Cargo.toml @@ -3,6 +3,7 @@ name = "packer" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = "0.5.2" diff --git a/packer/src/lib.rs b/packer/src/lib.rs index 31225931..e07784a0 100644 --- a/packer/src/lib.rs +++ b/packer/src/lib.rs @@ -1,21 +1,10 @@ -#[cfg(test)] -#[macro_use] -extern crate quickcheck; - -extern crate arrayvec; -extern crate buffer; -#[macro_use] -extern crate common; -#[cfg(feature = "uuid")] -extern crate uuid; -extern crate warn; - use arrayvec::ArrayVec; use buffer::with_buffer; use buffer::Buffer; use buffer::BufferRef; use buffer::CapacityError; use common::num::Cast; +use common::unwrap_or_return; use std::iter; use std::mem; use std::slice; @@ -427,6 +416,7 @@ fn string_to_bytes_buffer_ref<'d, 's>( #[rustfmt::skip] mod test { use arrayvec::ArrayVec; + use quickcheck::quickcheck; use std::i32; use super::Unpacker; use super::Warning::*; diff --git a/render_map/Cargo.toml b/render_map/Cargo.toml index 05aed4ae..1dbe52a3 100644 --- a/render_map/Cargo.toml +++ b/render_map/Cargo.toml @@ -3,6 +3,7 @@ name = "render_map" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] clap = "2.31.2" diff --git a/render_map/src/main.rs b/render_map/src/main.rs index 442a56d4..9ccf2675 100644 --- a/render_map/src/main.rs +++ b/render_map/src/main.rs @@ -1,20 +1,13 @@ #![cfg(not(test))] -#[macro_use] -extern crate clap; -extern crate common; -extern crate datafile as df; -extern crate image; -extern crate logger; -extern crate map; -extern crate ndarray; -extern crate num_traits; - +use clap::value_t; +use clap::values_t; use clap::App; use clap::Arg; use common::num::Cast; use common::slice; use common::vec; +use datafile as df; use image::imageops; use image::ImageError; use image::RgbaImage; diff --git a/server/Cargo.toml b/server/Cargo.toml index dc68dad9..ba9fdf86 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -3,13 +3,14 @@ name = "server" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = "0.5.2" common = { path = "../common/" } datafile = { path = "../datafile/" } event_loop = { path = "../event_loop/" } -gamenet_teeworlds_0_6 = { path = "../gamenet/teeworlds-0.6/" } +gamenet = { package = "gamenet_teeworlds_0_6", path = "../gamenet/teeworlds-0.6/" } hexdump = "0.1.1" itertools = ">=0.3.0,<0.5.0" log = "0.3.1" diff --git a/server/src/main.rs b/server/src/main.rs index 7930d6bb..52b1fff6 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -1,29 +1,12 @@ -extern crate arrayvec; -#[macro_use] -extern crate common; -extern crate datafile; -extern crate event_loop; -extern crate gamenet_teeworlds_0_6 as gamenet; -extern crate hexdump; -extern crate itertools; #[macro_use] extern crate log; -extern crate logger; -extern crate map; -#[macro_use] -extern crate matches; -extern crate ndarray; -extern crate packer; -extern crate snapshot; -extern crate socket; -extern crate warn; -extern crate world; use arrayvec::ArrayString; use arrayvec::ArrayVec; use common::num::Cast; use common::num::CastFloat; use common::pretty::AlmostString; +use common::unwrap_or_return; use common::Takeable; use event_loop::collections::PeerMap; use event_loop::collections::PeerSet; diff --git a/serverbrowse/Cargo.toml b/serverbrowse/Cargo.toml index 607b8311..af8c4afb 100644 --- a/serverbrowse/Cargo.toml +++ b/serverbrowse/Cargo.toml @@ -3,6 +3,7 @@ name = "serverbrowse" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = "0.5.2" diff --git a/serverbrowse/src/lib.rs b/serverbrowse/src/lib.rs index f6ab7a08..0faa3ff3 100644 --- a/serverbrowse/src/lib.rs +++ b/serverbrowse/src/lib.rs @@ -1,11 +1,4 @@ -extern crate arrayvec; -#[macro_use] -extern crate common; #[macro_use] extern crate log; -extern crate packer; -extern crate warn; -extern crate zerocopy; -extern crate zerocopy_derive; pub mod protocol; diff --git a/serverbrowse/src/protocol.rs b/serverbrowse/src/protocol.rs index 9cf29fca..aa3cbd92 100644 --- a/serverbrowse/src/protocol.rs +++ b/serverbrowse/src/protocol.rs @@ -1,7 +1,7 @@ use arrayvec::ArrayString; -use common; use common::num::Cast; use common::str::truncated_arraystring; +use common::unwrap_or_return; use packer::Unpacker; use std::default::Default; use std::fmt; diff --git a/snapshot/Cargo.toml b/snapshot/Cargo.toml index d13dece8..26e52878 100644 --- a/snapshot/Cargo.toml +++ b/snapshot/Cargo.toml @@ -3,11 +3,12 @@ name = "snapshot" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] buffer = "0.1.9" common = { path = "../common/" } -gamenet_teeworlds_0_6 = { path = "../gamenet/teeworlds-0.6/" } +gamenet = { package = "gamenet_teeworlds_0_6", path = "../gamenet/teeworlds-0.6/" } packer = { path = "../packer/" } vec_map = "0.8.0" warn = ">=0.1.1,<0.3.0" diff --git a/snapshot/src/format.rs b/snapshot/src/format.rs index e2d97c38..9daa18d1 100644 --- a/snapshot/src/format.rs +++ b/snapshot/src/format.rs @@ -1,8 +1,7 @@ +use crate::snap::Error; use buffer::CapacityError; -use packer; use packer::Packer; use packer::Unpacker; -use snap::Error; use warn::wrap; use warn::Warn; diff --git a/snapshot/src/lib.rs b/snapshot/src/lib.rs index ccde294f..9b697c33 100644 --- a/snapshot/src/lib.rs +++ b/snapshot/src/lib.rs @@ -1,23 +1,16 @@ -extern crate buffer; -extern crate common; -extern crate gamenet_teeworlds_0_6 as gamenet; -extern crate packer; -extern crate vec_map; -extern crate warn; - pub mod format; pub mod manager; pub mod receiver; pub mod snap; pub mod storage; -pub use manager::Manager; -pub use receiver::DeltaReceiver; -pub use receiver::ReceivedDelta; -pub use snap::Delta; -pub use snap::Snap; -pub use snap::SnapReader; -pub use storage::Storage; +pub use self::manager::Manager; +pub use self::receiver::DeltaReceiver; +pub use self::receiver::ReceivedDelta; +pub use self::snap::Delta; +pub use self::snap::Snap; +pub use self::snap::SnapReader; +pub use self::storage::Storage; use common::num::Cast; use std::ops; diff --git a/snapshot/src/manager.rs b/snapshot/src/manager.rs index b32d47a8..6006fb12 100644 --- a/snapshot/src/manager.rs +++ b/snapshot/src/manager.rs @@ -1,16 +1,16 @@ -use format; +use crate::format; +use crate::receiver; +use crate::snap; +use crate::storage; +use crate::Delta; +use crate::DeltaReceiver; +use crate::ReceivedDelta; +use crate::Snap; +use crate::Storage; use gamenet::msg::system; use packer::Unpacker; -use receiver; -use snap; -use storage; use warn::wrap; use warn::Warn; -use Delta; -use DeltaReceiver; -use ReceivedDelta; -use Snap; -use Storage; #[derive(Clone, Debug, Eq, PartialEq)] pub enum Error { diff --git a/snapshot/src/receiver.rs b/snapshot/src/receiver.rs index 9b8d22c4..1bacc22b 100644 --- a/snapshot/src/receiver.rs +++ b/snapshot/src/receiver.rs @@ -1,7 +1,7 @@ +use crate::to_usize; use common::num::Cast; use gamenet::msg::system; use std::ops; -use to_usize; use vec_map::VecMap; use warn::Warn; diff --git a/snapshot/src/snap.rs b/snapshot/src/snap.rs index af61e2e3..bbabbe68 100644 --- a/snapshot/src/snap.rs +++ b/snapshot/src/snap.rs @@ -1,15 +1,15 @@ +use crate::format::key; +use crate::format::key_to_id; +use crate::format::key_to_type_id; +use crate::format::DeltaHeader; +use crate::format::Item; +use crate::format::SnapHeader; +use crate::format::Warning; +use crate::to_usize; use buffer::CapacityError; use common::num::Cast; -use format::key; -use format::key_to_id; -use format::key_to_type_id; -use format::DeltaHeader; -use format::Item; -use format::SnapHeader; -use format::Warning; use gamenet::enums::MAX_SNAPSHOT_PACKSIZE; use gamenet::msg::system; -use packer; use packer::with_packer; use packer::Packer; use packer::Unpacker; @@ -21,7 +21,6 @@ use std::fmt; use std::iter; use std::mem; use std::ops; -use to_usize; use warn::wrap; use warn::Warn; diff --git a/snapshot/src/storage.rs b/snapshot/src/storage.rs index b9382381..d5e6d39c 100644 --- a/snapshot/src/storage.rs +++ b/snapshot/src/storage.rs @@ -1,8 +1,8 @@ -use format; -use snap; -use snap::Builder; -use snap::Delta; -use snap::Snap; +use crate::format; +use crate::snap; +use crate::snap::Builder; +use crate::snap::Delta; +use crate::snap::Snap; use std::collections::VecDeque; use warn::wrap; use warn::Warn; diff --git a/snapshot/tests/correctness.rs b/snapshot/tests/correctness.rs index 89c3081d..e842cda4 100644 --- a/snapshot/tests/correctness.rs +++ b/snapshot/tests/correctness.rs @@ -1,9 +1,3 @@ -extern crate buffer; -extern crate gamenet_teeworlds_0_6 as gamenet; -extern crate packer; -extern crate snapshot; -extern crate warn; - use buffer::CapacityError; use gamenet::snap_obj::obj_size; use packer::with_packer; diff --git a/socket/Cargo.toml b/socket/Cargo.toml index 7db6944d..935bd834 100644 --- a/socket/Cargo.toml +++ b/socket/Cargo.toml @@ -3,6 +3,7 @@ name = "socket" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] buffer = "0.1.9" diff --git a/socket/src/lib.rs b/socket/src/lib.rs index 239339a0..b263a494 100644 --- a/socket/src/lib.rs +++ b/socket/src/lib.rs @@ -1,19 +1,10 @@ -extern crate buffer; -#[macro_use] -extern crate common; -extern crate hexdump; -extern crate itertools; -extern crate libc; #[macro_use] extern crate log; -extern crate mio; -extern crate net; -extern crate net2; -extern crate rand; use buffer::with_buffer; use buffer::Buffer; use buffer::BufferRef; +use common::unwrap_or_return; use hexdump::hexdump_iter; use itertools::Itertools; use log::LogLevel; diff --git a/stats_browser/Cargo.toml b/stats_browser/Cargo.toml index 1c89260e..4dbe9fbf 100644 --- a/stats_browser/Cargo.toml +++ b/stats_browser/Cargo.toml @@ -3,6 +3,7 @@ name = "stats_browser" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [[bin]] name = "stats_browser" diff --git a/stats_browser/src/base64.rs b/stats_browser/src/base64.rs index dacb67eb..587148fd 100644 --- a/stats_browser/src/base64.rs +++ b/stats_browser/src/base64.rs @@ -1,5 +1,3 @@ -use base64_dep; - use std::fmt; /// A struct for printing a byte array as [Base64][wiki]. @@ -11,7 +9,7 @@ pub struct B64<'a>(pub &'a [u8]); impl<'a> fmt::Debug for B64<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let B64(bytes) = *self; - fmt::Display::fmt(&base64_dep::encode(bytes), f) + fmt::Display::fmt(&base64::encode(bytes), f) } } diff --git a/stats_browser/src/config.rs b/stats_browser/src/config.rs index 1b2a4647..683a930a 100644 --- a/stats_browser/src/config.rs +++ b/stats_browser/src/config.rs @@ -1,4 +1,4 @@ -use time::Duration; +use crate::time::Duration; /// Maximum number of malformed responses to report per server. pub const MAX_MALFORMED_RESP: u32 = 10; diff --git a/stats_browser/src/entry.rs b/stats_browser/src/entry.rs index 616c1ead..8dafed31 100644 --- a/stats_browser/src/entry.rs +++ b/stats_browser/src/entry.rs @@ -1,18 +1,15 @@ -use serverbrowse::protocol::PartialServerInfo; -use serverbrowse::protocol::ServerInfo; -use serverbrowse::protocol::Token7; - -use std::collections::HashSet; -use std::fmt; - -use addr::Addr; -use addr::ServerAddr; +use crate::addr::Addr; +use crate::addr::ServerAddr; use arrayvec::ArrayVec; use common::bytes::AsBytesExt; use common::bytes::FromBytesExt; -use rand; use rand::distributions; use rand::distributions::Distribution; +use serverbrowse::protocol::PartialServerInfo; +use serverbrowse::protocol::ServerInfo; +use serverbrowse::protocol::Token7; +use std::collections::HashSet; +use std::fmt; use zerocopy::byteorder::big_endian; /// Describes a master server. diff --git a/stats_browser/src/lib.rs b/stats_browser/src/lib.rs index be73fe24..adab93fc 100644 --- a/stats_browser/src/lib.rs +++ b/stats_browser/src/lib.rs @@ -1,25 +1,10 @@ #![cfg(not(test))] -extern crate arrayvec; -extern crate base64 as base64_dep; -extern crate csv; -extern crate ipnet; #[macro_use] extern crate log; -extern crate rand; -extern crate serde; -#[macro_use] -extern crate serde_derive; -extern crate time as rust_time; -extern crate uuid; -extern crate zerocopy; - -#[macro_use] -extern crate common; -extern crate serverbrowse; -pub use stats_browser::StatsBrowser; -pub use stats_browser::StatsBrowserCb; +pub use self::stats_browser::StatsBrowser; +pub use self::stats_browser::StatsBrowserCb; pub mod addr; pub mod base64; diff --git a/stats_browser/src/lookup.rs b/stats_browser/src/lookup.rs index a46b227b..8a925aaa 100644 --- a/stats_browser/src/lookup.rs +++ b/stats_browser/src/lookup.rs @@ -1,4 +1,4 @@ -use addr::Addr; +use crate::addr::Addr; use std::io; use std::net::ToSocketAddrs; diff --git a/stats_browser/src/main.rs b/stats_browser/src/main.rs index 58b9257e..d88d7608 100644 --- a/stats_browser/src/main.rs +++ b/stats_browser/src/main.rs @@ -1,11 +1,6 @@ #![cfg(not(test))] -#[macro_use] -extern crate clap; -extern crate logger; -extern crate stats_browser; -extern crate uuid; - +use clap::value_t; use clap::App; use clap::Arg; use clap::Values; diff --git a/stats_browser/src/socket.rs b/stats_browser/src/socket.rs index 13a5427b..e143402e 100644 --- a/stats_browser/src/socket.rs +++ b/stats_browser/src/socket.rs @@ -1,12 +1,8 @@ -extern crate mio; - -use self::mio::net::UdpSocket as MioUdpSocket; - +use crate::addr::Addr; +use mio::net::UdpSocket as MioUdpSocket; use std::fmt; use std::io; -use addr::Addr; - /// An unconnected non-blocking UDP socket. pub struct UdpSocket(MioUdpSocket); diff --git a/stats_browser/src/stats_browser.rs b/stats_browser/src/stats_browser.rs index a61b57d5..bf1c60a2 100644 --- a/stats_browser/src/stats_browser.rs +++ b/stats_browser/src/stats_browser.rs @@ -1,5 +1,25 @@ +use crate::addr::Addr; +use crate::addr::ProtocolVersion; +use crate::addr::ServerAddr; +use crate::config; +use crate::entry::MasterServerEntry; +use crate::entry::ServerEntry; +use crate::entry::ServerResponse; +use crate::entry::Token; +use crate::hashmap_ext::HashMapEntryIntoInner; +use crate::lookup::lookup_host; +use crate::socket::NonBlockExt; +use crate::socket::UdpSocket; +use crate::socket::WouldBlock; +use crate::time::Limit; +use crate::vec_map; +use crate::vec_map::VecMap; +use crate::work_queue::TimedWorkQueue; use common::num::Cast; use common::pretty::Bytes; +use rand::rngs::StdRng; +use rand::Rng; +use rand::SeedableRng; use serverbrowse::protocol; use serverbrowse::protocol::Count7Response; use serverbrowse::protocol::CountResponse; @@ -17,34 +37,12 @@ use serverbrowse::protocol::ServerInfo; use serverbrowse::protocol::Token7Response; use serverbrowse::protocol::MASTERSERVER_7_PORT; use serverbrowse::protocol::MASTERSERVER_PORT; - -use rand::rngs::StdRng; -use rand::Rng; -use rand::SeedableRng; use std::collections::HashMap; use std::collections::HashSet; use std::default::Default; use std::mem; use std::thread; -use addr::Addr; -use addr::ProtocolVersion; -use addr::ServerAddr; -use config; -use entry::MasterServerEntry; -use entry::ServerEntry; -use entry::ServerResponse; -use entry::Token; -use hashmap_ext::HashMapEntryIntoInner; -use lookup::lookup_host; -use socket::NonBlockExt; -use socket::UdpSocket; -use socket::WouldBlock; -use time::Limit; -use vec_map; -use vec_map::VecMap; -use work_queue::TimedWorkQueue; - pub trait StatsBrowserCb { fn on_server_new(&mut self, addr: ServerAddr, info: &ServerInfo); fn on_server_change(&mut self, addr: ServerAddr, old: &ServerInfo, new: &ServerInfo); diff --git a/stats_browser/src/time.rs b/stats_browser/src/time.rs index 8fbef148..29449c82 100644 --- a/stats_browser/src/time.rs +++ b/stats_browser/src/time.rs @@ -3,8 +3,6 @@ use std::ops::Add; use std::ops::Sub; use std::time as std_time; -use rust_time as time; - // TODO: What happens on time overflow? // TODO: What happens on time backward jump? diff --git a/stats_browser/src/tracker_fstd.rs b/stats_browser/src/tracker_fstd.rs index 8e5cad2d..c4cbddd8 100644 --- a/stats_browser/src/tracker_fstd.rs +++ b/stats_browser/src/tracker_fstd.rs @@ -1,18 +1,13 @@ +use crate::addr::Addr; +use crate::addr::ServerAddr; +use crate::base64::B64; +use crate::StatsBrowserCb; use serverbrowse::protocol::ClientInfo; use serverbrowse::protocol::ServerInfo; use serverbrowse::protocol::ServerInfoVersion; - use std::cmp::Ordering; use std::fmt; -use rust_time; - -use addr::Addr; -use addr::ServerAddr; -use base64::B64; - -use StatsBrowserCb; - #[allow(missing_copy_implementations)] pub struct Tracker { player_count: u32, @@ -171,7 +166,7 @@ impl StatsBrowserCb for Tracker { } fn print_iter<'a, I: Iterator>(command: &str, args: I) { - print!("{}\t{}", rust_time::get_time().sec, command); + print!("{}\t{}", time::get_time().sec, command); for a in args { print!("\t{}", a); } diff --git a/stats_browser/src/tracker_json.rs b/stats_browser/src/tracker_json.rs index e7b93625..b2c8a0b8 100644 --- a/stats_browser/src/tracker_json.rs +++ b/stats_browser/src/tracker_json.rs @@ -1,8 +1,10 @@ -use addr::ProtocolVersion; -use addr::ServerAddr; +use crate::addr::ProtocolVersion; +use crate::addr::ServerAddr; +use crate::StatsBrowserCb; use arrayvec::ArrayString; -use csv; use ipnet::Ipv4Net; +use serde_derive::Deserialize; +use serde_derive::Serialize; use serverbrowse::protocol::ClientInfo; use serverbrowse::protocol::IpAddr; use serverbrowse::protocol::ServerInfo; @@ -22,12 +24,12 @@ use std::thread; use std::time::Duration; use std::time::Instant; use uuid::Uuid; -use StatsBrowserCb; mod json { use super::Timestamp; - use addr; + use crate::addr; use arrayvec::ArrayString; + use serde_derive::Serialize; use serverbrowse::protocol; use std::collections::BTreeMap; use std::convert::TryFrom; diff --git a/stats_browser/src/vec_map.rs b/stats_browser/src/vec_map.rs index dc267d57..66864696 100644 --- a/stats_browser/src/vec_map.rs +++ b/stats_browser/src/vec_map.rs @@ -1,3 +1,4 @@ +use common::unwrap_or_return; use std::default::Default; use std::iter; use std::marker::PhantomData; diff --git a/stats_browser/src/work_queue.rs b/stats_browser/src/work_queue.rs index 5ab8c88d..0e34c1d4 100644 --- a/stats_browser/src/work_queue.rs +++ b/stats_browser/src/work_queue.rs @@ -1,3 +1,6 @@ +use crate::time::Duration; +use crate::time::Time; +use crate::time::Timed; use common::num::Cast; use std::collections::hash_map; use std::collections::hash_map::Entry; @@ -7,10 +10,6 @@ use std::collections::VecDeque; use std::default::Default; use std::iter; -use time::Duration; -use time::Time; -use time::Timed; - #[derive(Clone)] pub struct TimedWorkQueue { now_queue: VecDeque, diff --git a/teehistorian/Cargo.toml b/teehistorian/Cargo.toml index c704443e..062053cd 100644 --- a/teehistorian/Cargo.toml +++ b/teehistorian/Cargo.toml @@ -1,8 +1,9 @@ [package] -authors = ["heinrich5991 "] name = "teehistorian" version = "0.0.1" +authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = { version = "0.5.2", features = ["serde"] } diff --git a/teehistorian/src/bitmagic.rs b/teehistorian/src/bitmagic.rs index 46a25697..aa4107f0 100644 --- a/teehistorian/src/bitmagic.rs +++ b/teehistorian/src/bitmagic.rs @@ -1,8 +1,8 @@ +use crate::raw::Callback; use buffer::with_buffer; use buffer::Buffer; use buffer::BufferRef; - -use raw::Callback; +use common::unwrap_or_return; pub trait CallbackExt: Callback { fn read_buffer<'d, B: Buffer<'d>>(&mut self, buf: B) -> Result, Self::Error> { diff --git a/teehistorian/src/file.rs b/teehistorian/src/file.rs index 4faab504..d3220de0 100644 --- a/teehistorian/src/file.rs +++ b/teehistorian/src/file.rs @@ -1,18 +1,17 @@ +use crate::format; +use crate::format::item::INPUT_LEN; +use crate::format::Header; +use crate::raw; +use crate::raw::Callback; use std::fs::File; use std::io; use std::io::Read; use std::ops; use std::path::Path; -use format; -use format::item::INPUT_LEN; -use format::Header; -use raw; -use raw::Callback; - -pub use raw::Buffer; -pub use raw::Item; -pub use raw::Pos; +pub use crate::raw::Buffer; +pub use crate::raw::Item; +pub use crate::raw::Pos; #[derive(Debug)] pub enum Error { diff --git a/teehistorian/src/format/item.rs b/teehistorian/src/format/item.rs index a104ce00..66db8863 100644 --- a/teehistorian/src/format/item.rs +++ b/teehistorian/src/format/item.rs @@ -3,7 +3,6 @@ use common::num::Cast; use common::pretty; use packer::positive; use packer::Unpacker; -use serde; use serde::ser::SerializeSeq; use serde::Serialize; use std::fmt; diff --git a/teehistorian/src/format/mod.rs b/teehistorian/src/format/mod.rs index a36425b4..082a9dfd 100644 --- a/teehistorian/src/format/mod.rs +++ b/teehistorian/src/format/mod.rs @@ -3,7 +3,7 @@ use chrono::FixedOffset; use common::digest::Sha256; use packer::UnexpectedEnd; use packer::Unpacker; -use serde_json; +use serde_derive::Deserialize; use std::borrow::Cow; use std::collections::HashMap; use uuid::Uuid; diff --git a/teehistorian/src/lib.rs b/teehistorian/src/lib.rs index c8e90f5e..7931c2d4 100644 --- a/teehistorian/src/lib.rs +++ b/teehistorian/src/lib.rs @@ -1,29 +1,14 @@ -extern crate arrayvec; -extern crate buffer; -extern crate chrono; -#[macro_use] -extern crate common; -extern crate itertools; -extern crate packer; -extern crate serde; -#[macro_use] -extern crate serde_derive; -extern crate serde_json; -extern crate uuid; -extern crate vec_map; -extern crate warn; - mod bitmagic; mod file; pub mod format; mod raw; -pub use file::Buffer; -pub use file::Error; -pub use file::Item; -pub use file::Reader; -pub use raw::Header; -pub use raw::Input; -pub use raw::Player; -pub use raw::PlayerChange; -pub use raw::Pos; +pub use self::file::Buffer; +pub use self::file::Error; +pub use self::file::Item; +pub use self::file::Reader; +pub use self::raw::Header; +pub use self::raw::Input; +pub use self::raw::Player; +pub use self::raw::PlayerChange; +pub use self::raw::Pos; diff --git a/teehistorian/src/raw.rs b/teehistorian/src/raw.rs index c0c95ec8..7b01b30d 100644 --- a/teehistorian/src/raw.rs +++ b/teehistorian/src/raw.rs @@ -1,18 +1,18 @@ +use crate::bitmagic::CallbackExt; +use crate::format; +use crate::format::item; +use crate::format::item::INPUT_LEN; +use crate::format::MaybeEnd; use common::num::Cast; use itertools::zip_eq; use packer::Unpacker; +use serde_derive::Serialize; use std::cmp; use std::fmt; use std::ops; use vec_map::VecMap; -use bitmagic::CallbackExt; -use format; -use format::item; -use format::item::INPUT_LEN; -use format::MaybeEnd; - -pub use format::Header; +pub use crate::format::Header; macro_rules! unexp_end { ($e:expr) => { diff --git a/tools/Cargo.toml b/tools/Cargo.toml index b7992f99..964bb9bb 100644 --- a/tools/Cargo.toml +++ b/tools/Cargo.toml @@ -3,6 +3,7 @@ name = "tools" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] arrayvec = "0.5.2" diff --git a/tools/src/bin/author.rs b/tools/src/bin/author.rs index 73ff5174..318e99dc 100644 --- a/tools/src/bin/author.rs +++ b/tools/src/bin/author.rs @@ -1,10 +1,6 @@ #![cfg(not(test))] -extern crate common; -extern crate datafile as df; -extern crate map; -extern crate tools; - +use datafile as df; use map::format; use std::path::Path; diff --git a/tools/src/bin/basic.rs b/tools/src/bin/basic.rs index 2b02c679..e7e6a79e 100644 --- a/tools/src/bin/basic.rs +++ b/tools/src/bin/basic.rs @@ -1,9 +1,6 @@ #![cfg(not(test))] -extern crate datafile as df; -extern crate map; -extern crate tools; - +use datafile as df; use std::path::Path; fn process(_: &Path, _: df::Reader, _: &mut ()) -> Result<(), map::Error> { diff --git a/tools/src/bin/datafile.rs b/tools/src/bin/datafile.rs index f3656e82..eb44f20b 100644 --- a/tools/src/bin/datafile.rs +++ b/tools/src/bin/datafile.rs @@ -1,9 +1,6 @@ #![cfg(not(test))] -extern crate datafile as df; -extern crate map; -extern crate tools; - +use datafile as df; use std::path::Path; fn process(_: &Path, mut df: df::Reader, _: &mut ()) -> Result<(), map::Error> { diff --git a/tools/src/bin/ddnet_emptytele.rs b/tools/src/bin/ddnet_emptytele.rs index 59e46e95..417bc970 100644 --- a/tools/src/bin/ddnet_emptytele.rs +++ b/tools/src/bin/ddnet_emptytele.rs @@ -1,8 +1,3 @@ -extern crate clap; -extern crate datafile; -extern crate logger; -extern crate map; - use map::Error; use std::path::Path; use std::process; diff --git a/tools/src/bin/ddnet_properties.rs b/tools/src/bin/ddnet_properties.rs index be1d13b9..2268ba44 100644 --- a/tools/src/bin/ddnet_properties.rs +++ b/tools/src/bin/ddnet_properties.rs @@ -1,10 +1,3 @@ -extern crate clap; -extern crate common; -extern crate datafile; -extern crate logger; -extern crate map; -extern crate rmp; - use common::num::Cast; use map::format::SpeedupTile; use map::format::SwitchTile; diff --git a/tools/src/bin/demo_info.rs b/tools/src/bin/demo_info.rs index 31956ff4..34ab6437 100644 --- a/tools/src/bin/demo_info.rs +++ b/tools/src/bin/demo_info.rs @@ -1,9 +1,4 @@ -extern crate demo; extern crate gamenet_teeworlds_0_6 as gamenet; -extern crate hexdump; -extern crate logger; -extern crate packer; -extern crate warn; use gamenet::msg::Game; use std::collections::HashMap; diff --git a/tools/src/bin/demo_read_write.rs b/tools/src/bin/demo_read_write.rs index 4b37e472..fa0da3fd 100644 --- a/tools/src/bin/demo_read_write.rs +++ b/tools/src/bin/demo_read_write.rs @@ -1,7 +1,3 @@ -extern crate clap; -extern crate demo; -extern crate logger; - use clap::App; use clap::Arg; use demo::ddnet; diff --git a/tools/src/bin/entities.rs b/tools/src/bin/entities.rs index ee3bc6fc..fc6b7cab 100644 --- a/tools/src/bin/entities.rs +++ b/tools/src/bin/entities.rs @@ -1,11 +1,7 @@ #![cfg(not(test))] -extern crate common; -extern crate datafile as df; -extern crate map; -extern crate tools; - use common::num::Cast; +use datafile as df; use std::path::Path; use tools::map_stats::Entity; diff --git a/tools/src/bin/entities_flags.rs b/tools/src/bin/entities_flags.rs index f40a6a59..2e65143f 100644 --- a/tools/src/bin/entities_flags.rs +++ b/tools/src/bin/entities_flags.rs @@ -1,11 +1,7 @@ #![cfg(not(test))] -extern crate common; -extern crate datafile as df; -extern crate map; -extern crate tools; - use common::num::Cast; +use datafile as df; use std::path::Path; use tools::map_stats::Entity; diff --git a/tools/src/bin/gamelayers.rs b/tools/src/bin/gamelayers.rs index b3e53070..646114f0 100644 --- a/tools/src/bin/gamelayers.rs +++ b/tools/src/bin/gamelayers.rs @@ -1,9 +1,6 @@ #![cfg(not(test))] -extern crate datafile as df; -extern crate map; -extern crate tools; - +use datafile as df; use std::path::Path; #[derive(Default)] diff --git a/tools/src/bin/integer.rs b/tools/src/bin/integer.rs index acb86620..91b7478c 100644 --- a/tools/src/bin/integer.rs +++ b/tools/src/bin/integer.rs @@ -1,9 +1,3 @@ -extern crate arrayvec; -extern crate clap; -extern crate hexdump; -extern crate packer; -extern crate tools; - use arrayvec::ArrayVec; use clap::App; use clap::Arg; diff --git a/tools/src/bin/item_lengths.rs b/tools/src/bin/item_lengths.rs index c84ebf85..7509fb99 100644 --- a/tools/src/bin/item_lengths.rs +++ b/tools/src/bin/item_lengths.rs @@ -1,9 +1,6 @@ #![cfg(not(test))] -extern crate datafile as df; -extern crate map; -extern crate tools; - +use datafile as df; use map::format::*; use std::collections::HashMap; use std::fmt; diff --git a/tools/src/bin/jungle.rs b/tools/src/bin/jungle.rs index 40469d97..17c7ae2c 100644 --- a/tools/src/bin/jungle.rs +++ b/tools/src/bin/jungle.rs @@ -1,9 +1,6 @@ #![cfg(not(test))] -extern crate datafile as df; -extern crate map; -extern crate tools; - +use datafile as df; use map::reader; use std::collections::HashMap; use std::path::Path; diff --git a/tools/src/bin/jungle2.rs b/tools/src/bin/jungle2.rs index 22a29472..1b516f92 100644 --- a/tools/src/bin/jungle2.rs +++ b/tools/src/bin/jungle2.rs @@ -1,11 +1,7 @@ #![cfg(not(test))] -extern crate common; -extern crate datafile as df; -extern crate map; -extern crate tools; - use common::num::Cast; +use datafile as df; use map::reader; use std::cmp; use std::collections::hash_map; diff --git a/tools/src/bin/ok.rs b/tools/src/bin/ok.rs index 000f6977..d16704a8 100644 --- a/tools/src/bin/ok.rs +++ b/tools/src/bin/ok.rs @@ -1,9 +1,6 @@ #![cfg(not(test))] -extern crate datafile as df; -extern crate map; -extern crate tools; - +use datafile as df; use std::path::Path; fn process(p: &Path, _: df::Reader, _: &mut ()) -> Result<(), map::Error> { diff --git a/tools/src/bin/packet_decode.rs b/tools/src/bin/packet_decode.rs index 6c74528a..d772a9ec 100644 --- a/tools/src/bin/packet_decode.rs +++ b/tools/src/bin/packet_decode.rs @@ -1,11 +1,4 @@ -extern crate arrayvec; -extern crate buffer; extern crate gamenet_teeworlds_0_6 as gamenet; -extern crate hexdump; -extern crate net; -extern crate packer; -extern crate tools; -extern crate warn; use arrayvec::ArrayVec; use buffer::ReadBuffer; diff --git a/tools/src/bin/raw.rs b/tools/src/bin/raw.rs index c7c0c105..88ae5ff2 100644 --- a/tools/src/bin/raw.rs +++ b/tools/src/bin/raw.rs @@ -1,14 +1,9 @@ #![cfg(not(test))] -extern crate datafile; -extern crate map; -extern crate tools; - +use map::format::*; use std::fmt::Debug; use std::path::Path; -use map::format::*; - fn process(_: &Path, dfr: datafile::Reader, _: &mut ()) -> Result<(), map::Error> { let mut env_version = None; diff --git a/tools/src/bin/servercount.rs b/tools/src/bin/servercount.rs index 91e3d370..9c11aa66 100644 --- a/tools/src/bin/servercount.rs +++ b/tools/src/bin/servercount.rs @@ -2,13 +2,10 @@ #[macro_use] extern crate log; -extern crate serverbrowse; -extern crate tools; use serverbrowse::protocol as browse_protocol; use serverbrowse::protocol::CountResponse; use serverbrowse::protocol::Response; - use std::net::SocketAddr; use std::net::UdpSocket; diff --git a/tools/src/bin/servercount7.rs b/tools/src/bin/servercount7.rs index f9674bc7..0abd3bbf 100644 --- a/tools/src/bin/servercount7.rs +++ b/tools/src/bin/servercount7.rs @@ -2,15 +2,12 @@ #[macro_use] extern crate log; -extern crate serverbrowse; -extern crate tools; use serverbrowse::protocol as browse_protocol; use serverbrowse::protocol::Count7Response; use serverbrowse::protocol::Response; use serverbrowse::protocol::Token7; use serverbrowse::protocol::Token7Response; - use std::net::SocketAddr; use std::net::UdpSocket; diff --git a/tools/src/bin/serverinfo.rs b/tools/src/bin/serverinfo.rs index 4dabca68..f3e68cee 100644 --- a/tools/src/bin/serverinfo.rs +++ b/tools/src/bin/serverinfo.rs @@ -2,12 +2,9 @@ #[macro_use] extern crate log; -extern crate serverbrowse; -extern crate tools; use serverbrowse::protocol as browse_protocol; use serverbrowse::protocol::Response; - use std::net::SocketAddr; use std::net::UdpSocket; diff --git a/tools/src/bin/serverinfo7.rs b/tools/src/bin/serverinfo7.rs index ba367969..8a35fc09 100644 --- a/tools/src/bin/serverinfo7.rs +++ b/tools/src/bin/serverinfo7.rs @@ -2,14 +2,11 @@ #[macro_use] extern crate log; -extern crate serverbrowse; -extern crate tools; use serverbrowse::protocol as browse_protocol; use serverbrowse::protocol::Response; use serverbrowse::protocol::Token7; use serverbrowse::protocol::Token7Response; - use std::net::SocketAddr; use std::net::UdpSocket; diff --git a/tools/src/bin/serverlist.rs b/tools/src/bin/serverlist.rs index 00743afc..a83cf4f2 100644 --- a/tools/src/bin/serverlist.rs +++ b/tools/src/bin/serverlist.rs @@ -2,13 +2,10 @@ #[macro_use] extern crate log; -extern crate serverbrowse; -extern crate tools; use serverbrowse::protocol as browse_protocol; use serverbrowse::protocol::List6Response; use serverbrowse::protocol::Response; - use std::net::SocketAddr; use std::net::UdpSocket; diff --git a/tools/src/bin/serverlist7.rs b/tools/src/bin/serverlist7.rs index 2c488898..80e60889 100644 --- a/tools/src/bin/serverlist7.rs +++ b/tools/src/bin/serverlist7.rs @@ -2,15 +2,12 @@ #[macro_use] extern crate log; -extern crate serverbrowse; -extern crate tools; use serverbrowse::protocol as browse_protocol; use serverbrowse::protocol::List7Response; use serverbrowse::protocol::Response; use serverbrowse::protocol::Token7; use serverbrowse::protocol::Token7Response; - use std::net::SocketAddr; use std::net::UdpSocket; diff --git a/tools/src/bin/settings.rs b/tools/src/bin/settings.rs index 0b8124c3..af674469 100644 --- a/tools/src/bin/settings.rs +++ b/tools/src/bin/settings.rs @@ -1,11 +1,7 @@ #![cfg(not(test))] -extern crate common; -extern crate datafile as df; -extern crate map; -extern crate tools; - use common::pretty; +use datafile as df; use map::format; use std::path::Path; diff --git a/tools/src/bin/teehistorian2demo.rs b/tools/src/bin/teehistorian2demo.rs index 29d39d70..ce615073 100644 --- a/tools/src/bin/teehistorian2demo.rs +++ b/tools/src/bin/teehistorian2demo.rs @@ -1,17 +1,3 @@ -extern crate arrayvec; -extern crate clap; -extern crate common; -extern crate demo; -extern crate gamenet_ddnet; -extern crate gamenet_teeworlds_0_7; -extern crate logger; -extern crate packer; -extern crate snapshot; -extern crate teehistorian; -extern crate vec_map; -extern crate warn; -extern crate world; - use arrayvec::ArrayVec; use common::num::Cast; use demo::Writer; diff --git a/tools/src/bin/teehistorian_dump.rs b/tools/src/bin/teehistorian_dump.rs index def9b10c..0013ac19 100644 --- a/tools/src/bin/teehistorian_dump.rs +++ b/tools/src/bin/teehistorian_dump.rs @@ -1,13 +1,6 @@ -extern crate buffer; -extern crate clap; extern crate gamenet_teeworlds_0_6 as gamenet; -extern crate logger; -#[macro_use] -extern crate serde_derive; -extern crate serde_json; -extern crate teehistorian; -extern crate warn; +use serde_derive::Serialize; use std::io; use std::path::Path; use std::process; diff --git a/tools/src/bin/teehistorian_index.rs b/tools/src/bin/teehistorian_index.rs index cff36f0e..e9aec41f 100644 --- a/tools/src/bin/teehistorian_index.rs +++ b/tools/src/bin/teehistorian_index.rs @@ -1,19 +1,9 @@ -extern crate chrono; -extern crate clap; -extern crate csv; -extern crate itertools; -extern crate logger; -extern crate serde; -#[macro_use] -extern crate serde_derive; -extern crate teehistorian; -extern crate uuid; -extern crate walkdir; - use chrono::DateTime; use chrono::FixedOffset; use itertools::sorted; use itertools::Itertools; +use serde_derive::Deserialize; +use serde_derive::Serialize; use std::borrow::Cow; use std::ffi::OsStr; use std::fmt; diff --git a/tools/src/bin/teehistorian_index_resetfile.rs b/tools/src/bin/teehistorian_index_resetfile.rs index a432a92a..73f39407 100644 --- a/tools/src/bin/teehistorian_index_resetfile.rs +++ b/tools/src/bin/teehistorian_index_resetfile.rs @@ -1,19 +1,9 @@ -extern crate chrono; -extern crate clap; -extern crate csv; -extern crate itertools; -extern crate logger; -extern crate serde; -#[macro_use] -extern crate serde_derive; -extern crate teehistorian; -extern crate uuid; -extern crate walkdir; - use chrono::DateTime; use chrono::FixedOffset; use itertools::sorted; use itertools::Itertools; +use serde_derive::Deserialize; +use serde_derive::Serialize; use std::borrow::Cow; use std::ffi::OsStr; use std::fmt; diff --git a/tools/src/bin/teehistorian_nonsolo_solo.rs b/tools/src/bin/teehistorian_nonsolo_solo.rs index 74f761f7..90b81dae 100644 --- a/tools/src/bin/teehistorian_nonsolo_solo.rs +++ b/tools/src/bin/teehistorian_nonsolo_solo.rs @@ -1,16 +1,5 @@ -extern crate chrono; -extern crate clap; -extern crate csv; -extern crate itertools; -extern crate logger; -extern crate serde; -#[macro_use] -extern crate serde_derive; -extern crate teehistorian; -extern crate uuid; -extern crate walkdir; - use itertools::sorted; +use serde_derive::Serialize; use std::borrow::Cow; use std::ffi::OsStr; use std::io; diff --git a/tools/src/bin/teehistorian_odd.rs b/tools/src/bin/teehistorian_odd.rs index 821fb522..cbd1b0c0 100644 --- a/tools/src/bin/teehistorian_odd.rs +++ b/tools/src/bin/teehistorian_odd.rs @@ -1,13 +1,4 @@ -extern crate arrayvec; -extern crate buffer; -extern crate clap; -extern crate common; extern crate gamenet_teeworlds_0_6 as gamenet; -extern crate logger; -extern crate packer; -extern crate teehistorian; -extern crate vec_map; -extern crate warn; use arrayvec::ArrayVec; use common::num::Cast; diff --git a/tools/src/bin/teehistorian_saves.rs b/tools/src/bin/teehistorian_saves.rs index 32311bcb..e37d9873 100644 --- a/tools/src/bin/teehistorian_saves.rs +++ b/tools/src/bin/teehistorian_saves.rs @@ -1,16 +1,3 @@ -extern crate arrayvec; -extern crate buffer; -extern crate clap; -extern crate common; -extern crate gamenet_ddnet; -extern crate gamenet_teeworlds_0_7; -extern crate logger; -extern crate packer; -extern crate teehistorian; -extern crate uuid; -extern crate vec_map; -extern crate warn; - use arrayvec::ArrayVec; use common::num::Cast; use common::pretty; diff --git a/tools/src/bin/test_gamenet_spec.rs b/tools/src/bin/test_gamenet_spec.rs index 4ffd8312..8a8abbc8 100644 --- a/tools/src/bin/test_gamenet_spec.rs +++ b/tools/src/bin/test_gamenet_spec.rs @@ -1,8 +1,3 @@ -extern crate clap; -extern crate gamenet_spec; -extern crate logger; -extern crate serde_json; - use std::error::Error; use std::fs::File; use std::path::Path; diff --git a/tools/src/bin/tune_layer.rs b/tools/src/bin/tune_layer.rs index 78a5094e..507da9a6 100644 --- a/tools/src/bin/tune_layer.rs +++ b/tools/src/bin/tune_layer.rs @@ -1,12 +1,8 @@ #![cfg(not(test))] -#[macro_use] -extern crate common; -extern crate datafile as df; -extern crate map; -extern crate tools; - use common::num::Cast; +use common::unwrap_or_return; +use datafile as df; use std::fmt; use std::path::Path; diff --git a/tools/src/bin/versions.rs b/tools/src/bin/versions.rs index 8a7a62bf..a6449eb5 100644 --- a/tools/src/bin/versions.rs +++ b/tools/src/bin/versions.rs @@ -1,9 +1,5 @@ #![cfg(not(test))] -extern crate datafile; -extern crate map; -extern crate tools; - use datafile::Version as DfVersion; use std::io; use std::io::Write; diff --git a/tools/src/client.rs b/tools/src/client.rs index 99355e41..086cd2cd 100644 --- a/tools/src/client.rs +++ b/tools/src/client.rs @@ -1,4 +1,3 @@ -use logger; use std::env; use std::net::SocketAddr; use std::net::ToSocketAddrs; diff --git a/tools/src/lib.rs b/tools/src/lib.rs index bf55dfdf..406b46ac 100644 --- a/tools/src/lib.rs +++ b/tools/src/lib.rs @@ -1,8 +1,3 @@ -extern crate datafile as df; -extern crate logger; -extern crate map; -extern crate warn; - pub mod client; pub mod map_stats; pub mod unhexdump; diff --git a/tools/src/map_stats.rs b/tools/src/map_stats.rs index af44b646..be7bb031 100644 --- a/tools/src/map_stats.rs +++ b/tools/src/map_stats.rs @@ -1,6 +1,4 @@ -use df; -use logger; -use map; +use datafile as df; use std::collections::HashMap; use std::env; use std::fmt; diff --git a/uniffi/Cargo.toml b/uniffi/Cargo.toml index 090f2f5f..219fb2fa 100644 --- a/uniffi/Cargo.toml +++ b/uniffi/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "bindgen", "huffman", diff --git a/uniffi/bindgen/Cargo.toml b/uniffi/bindgen/Cargo.toml index d692b61d..e4dba904 100644 --- a/uniffi/bindgen/Cargo.toml +++ b/uniffi/bindgen/Cargo.toml @@ -3,6 +3,7 @@ name = "uniffi-bindgen" version = "0.2.0" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] uniffi = { git = "https://github.com/mozilla/uniffi-rs", rev = "62979fa0899b74f29db48d715da20ea514e400fe", features = ["cli"] } diff --git a/uniffi/bindgen/src/main.rs b/uniffi/bindgen/src/main.rs index ddb5b3ef..f6cff6cf 100644 --- a/uniffi/bindgen/src/main.rs +++ b/uniffi/bindgen/src/main.rs @@ -1,5 +1,3 @@ -extern crate uniffi; - fn main() { uniffi::uniffi_bindgen_main() } diff --git a/uniffi/huffman/Cargo.toml b/uniffi/huffman/Cargo.toml index 89cdd0fd..4cb0dce8 100644 --- a/uniffi/huffman/Cargo.toml +++ b/uniffi/huffman/Cargo.toml @@ -3,6 +3,7 @@ name = "uniffi-huffman" version = "0.2.0" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [lib] name = "libtw2_huffman" diff --git a/uniffi/huffman/src/lib.rs b/uniffi/huffman/src/lib.rs index a67bfe8e..3e077b21 100644 --- a/uniffi/huffman/src/lib.rs +++ b/uniffi/huffman/src/lib.rs @@ -1,6 +1,3 @@ -extern crate huffman; -extern crate uniffi; - use std::error; use std::fmt; diff --git a/wireshark-dissector/Cargo.toml b/wireshark-dissector/Cargo.toml index 8a8385db..8a93ee10 100644 --- a/wireshark-dissector/Cargo.toml +++ b/wireshark-dissector/Cargo.toml @@ -3,6 +3,7 @@ name = "wireshark-dissector" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [lib] crate-type = ["cdylib"] diff --git a/wireshark-dissector/build.rs b/wireshark-dissector/build.rs index badcc9bb..daf63278 100644 --- a/wireshark-dissector/build.rs +++ b/wireshark-dissector/build.rs @@ -1,5 +1,3 @@ -extern crate cc; - use std::env; use std::path::PathBuf; diff --git a/wireshark-dissector/src/lib.rs b/wireshark-dissector/src/lib.rs index 881ee084..2f0cc7da 100644 --- a/wireshark-dissector/src/lib.rs +++ b/wireshark-dissector/src/lib.rs @@ -1,19 +1,4 @@ -extern crate anyhow; -extern crate arrayvec; -#[macro_use] -extern crate common; -extern crate gamenet_common; -extern crate gamenet_spec; -extern crate huffman; -#[cfg(test)] -extern crate lazy_static; -extern crate net; -extern crate packer; -extern crate serde_json; -extern crate uuid; -extern crate warn; extern crate wireshark_dissector_sys as sys; -extern crate zerocopy; mod format; mod intern; diff --git a/wireshark-dissector/src/spec.rs b/wireshark-dissector/src/spec.rs index 36d80661..48432ac9 100644 --- a/wireshark-dissector/src/spec.rs +++ b/wireshark-dissector/src/spec.rs @@ -1,5 +1,12 @@ use crate::c; +use crate::format::Bitfield; +use crate::format::CommaSeparated; +use crate::format::NumBytes; +use crate::intern::intern; +use crate::intern::intern_static_with_nul; +use crate::intern::Interned; use crate::to_guid; +use crate::IdentifierEx; use crate::HFRI_DEFAULT; use anyhow::anyhow; use anyhow::bail; @@ -8,13 +15,8 @@ use arrayvec::ArrayVec; use common::digest; use common::num::Cast; use common::pretty::AlmostString; -use format::Bitfield; -use format::CommaSeparated; -use format::NumBytes; +use common::unwrap_or; use gamenet_spec::MessageId; -use intern::intern; -use intern::intern_static_with_nul; -use intern::Interned; use packer::Unpacker; use std::cell::Cell; use std::collections::HashMap; @@ -30,7 +32,6 @@ use std::os::raw::c_uint; use std::rc::Rc; use std::str; use warn::Ignore; -use IdentifierEx; #[derive(Debug)] pub struct Spec { diff --git a/wireshark-dissector/src/tw.rs b/wireshark-dissector/src/tw.rs index 7c66b5e2..70b6330b 100644 --- a/wireshark-dissector/src/tw.rs +++ b/wireshark-dissector/src/tw.rs @@ -1,16 +1,16 @@ use crate::c; +use crate::format::Bitfield; +use crate::format::CommaSeparated; +use crate::format::NumBytes; +use crate::intern::intern_static_with_nul; +use crate::spec::Spec; use crate::Counter; use crate::HFRI_DEFAULT; use arrayvec::ArrayVec; use common::num::Cast; use common::pretty; -use format::Bitfield; -use format::CommaSeparated; -use format::NumBytes; -use intern::intern_static_with_nul; use net::protocol; use packer::Unpacker; -use spec::Spec; use std::ffi::CStr; use std::ffi::CString; use std::io::Write; @@ -868,7 +868,7 @@ fn register_chunk_protocol(spec: &Spec) { mod test { #[test] fn spec_valid() { - use test; + use crate::test; let _guard = test::TEST_MUTEX.lock().unwrap(); super::load_spec().expect("invalid spec"); } diff --git a/wireshark-dissector/src/tw7.rs b/wireshark-dissector/src/tw7.rs index f6e2870a..38fcec3b 100644 --- a/wireshark-dissector/src/tw7.rs +++ b/wireshark-dissector/src/tw7.rs @@ -1,16 +1,16 @@ use crate::c; +use crate::format::Bitfield; +use crate::format::CommaSeparated; +use crate::format::NumBytes; +use crate::intern::intern_static_with_nul; +use crate::spec::Spec; use crate::Counter; use crate::HFRI_DEFAULT; use arrayvec::ArrayVec; use common::num::Cast; use common::pretty; -use format::Bitfield; -use format::CommaSeparated; -use format::NumBytes; -use intern::intern_static_with_nul; use net::protocol7 as protocol; use packer::Unpacker; -use spec::Spec; use std::ffi::CStr; use std::ffi::CString; use std::io::Write; @@ -901,7 +901,7 @@ fn register_chunk_protocol(spec: &Spec) { mod test { #[test] fn spec_valid() { - use test; + use crate::test; let _guard = test::TEST_MUTEX.lock().unwrap(); super::load_spec().expect("invalid spec"); } diff --git a/wireshark-dissector/sys/Cargo.toml b/wireshark-dissector/sys/Cargo.toml index 31ebebd8..934bd265 100644 --- a/wireshark-dissector/sys/Cargo.toml +++ b/wireshark-dissector/sys/Cargo.toml @@ -3,5 +3,6 @@ name = "wireshark-dissector-sys" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] diff --git a/world/Cargo.toml b/world/Cargo.toml index fe2fd850..b3072a67 100644 --- a/world/Cargo.toml +++ b/world/Cargo.toml @@ -3,7 +3,8 @@ name = "world" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] common = { path = "../common/" } -gamenet_teeworlds_0_6 = { path = "../gamenet/teeworlds-0.6/" } +gamenet = { package = "gamenet_teeworlds_0_6", path = "../gamenet/teeworlds-0.6/" } diff --git a/world/src/lib.rs b/world/src/lib.rs index 89cac965..3aa33370 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -1,6 +1,3 @@ -extern crate common; -extern crate gamenet_teeworlds_0_6 as gamenet; - use common::num::Cast; use common::num::CastFloat; use gamenet::msg::game::SvTuneParams; diff --git a/zlib_minimal/Cargo.toml b/zlib_minimal/Cargo.toml index b9911908..67fe1f67 100644 --- a/zlib_minimal/Cargo.toml +++ b/zlib_minimal/Cargo.toml @@ -3,6 +3,7 @@ name = "zlib_minimal" version = "0.0.1" authors = ["heinrich5991 "] license = "MIT/Apache-2.0" +edition = "2021" [dependencies] libc = ">=0.1.5,<0.3.0" diff --git a/zlib_minimal/src/lib.rs b/zlib_minimal/src/lib.rs index c5f57234..202bf21a 100644 --- a/zlib_minimal/src/lib.rs +++ b/zlib_minimal/src/lib.rs @@ -3,7 +3,6 @@ //! This wrapper only exposes the `uncompress` method of zlib, both without //! indirection and as idiomatic Rust function. -extern crate libc; extern crate libz_sys as raw; use libc::c_ulong;