mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
[Crate] Bump rustfmt version to 1.6.0 (#69)
This commit is contained in:
parent
bf8c087b94
commit
fb9d15f0cc
5 changed files with 96 additions and 96 deletions
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
|
@ -24,10 +24,10 @@ jobs:
|
||||||
- name: Install Formatting nightly
|
- name: Install Formatting nightly
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: nightly-2023-03-01
|
toolchain: nightly-2023-07-09
|
||||||
components: rustfmt
|
components: rustfmt
|
||||||
- name: Run Formatting check
|
- name: Run Formatting check
|
||||||
run: cargo +nightly-2023-03-01 fmt --check --verbose
|
run: cargo +nightly-2023-07-09 fmt --check --verbose
|
||||||
- name: Install MSRV
|
- name: Install MSRV
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ repos:
|
||||||
language: system
|
language: system
|
||||||
files: '[.]rs$'
|
files: '[.]rs$'
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
entry: rustup run --install nightly-2023-03-01 cargo-clippy -- -- -D warnings
|
entry: rustup run --install nightly-2023-07-09 cargo-clippy -- -- -D warnings
|
||||||
- id: format
|
- id: format
|
||||||
name: Check rustfmt
|
name: Check rustfmt
|
||||||
language: system
|
language: system
|
||||||
files: '[.]rs$'
|
files: '[.]rs$'
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
entry: rustup run --install nightly-2023-03-01 cargo-fmt --check
|
entry: rustup run --install nightly-2023-07-09 cargo-fmt --check
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ overflow_delimited_expr = false
|
||||||
reorder_impl_items = false
|
reorder_impl_items = false
|
||||||
reorder_imports = true
|
reorder_imports = true
|
||||||
reorder_modules = true
|
reorder_modules = true
|
||||||
required_version = "1.5.2"
|
required_version = "1.6.0"
|
||||||
short_array_element_width_threshold = 10
|
short_array_element_width_threshold = 10
|
||||||
single_line_if_else_max_width = 50
|
single_line_if_else_max_width = 50
|
||||||
skip_children = false
|
skip_children = false
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ Places to update:
|
||||||
|
|
||||||
# rustfmt version
|
# rustfmt version
|
||||||
|
|
||||||
Current: `1.5.2`
|
Current: `1.6.0`
|
||||||
|
|
||||||
Places to update:
|
Places to update:
|
||||||
- `.rustfmt.toml`
|
- `.rustfmt.toml`
|
||||||
|
|
@ -19,7 +19,7 @@ Places to update:
|
||||||
|
|
||||||
The toolchain version used to run rustfmt in CI
|
The toolchain version used to run rustfmt in CI
|
||||||
|
|
||||||
Current: `nightly-2023-03-01`
|
Current: `nightly-2023-07-09`
|
||||||
|
|
||||||
Places to update:
|
Places to update:
|
||||||
- `./.github/workflows/ci.yml`
|
- `./.github/workflows/ci.yml`
|
||||||
|
|
|
||||||
178
src/errors.rs
178
src/errors.rs
|
|
@ -1,89 +1,89 @@
|
||||||
use std::{
|
use std::{
|
||||||
error::Error,
|
error::Error,
|
||||||
fmt::{self, Formatter},
|
fmt::{self, Formatter},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Result of Type and GDError.
|
/// Result of Type and GDError.
|
||||||
pub type GDResult<T> = Result<T, GDError>;
|
pub type GDResult<T> = Result<T, GDError>;
|
||||||
|
|
||||||
/// GameDig Error.
|
/// GameDig Error.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum GDError {
|
pub enum GDError {
|
||||||
/// The received packet was bigger than the buffer size.
|
/// The received packet was bigger than the buffer size.
|
||||||
PacketOverflow,
|
PacketOverflow,
|
||||||
/// The received packet was shorter than the expected one.
|
/// The received packet was shorter than the expected one.
|
||||||
PacketUnderflow,
|
PacketUnderflow,
|
||||||
/// The received packet is badly formatted.
|
/// The received packet is badly formatted.
|
||||||
PacketBad,
|
PacketBad,
|
||||||
/// Couldn't send the packet.
|
/// Couldn't send the packet.
|
||||||
PacketSend,
|
PacketSend,
|
||||||
/// Couldn't send the receive.
|
/// Couldn't send the receive.
|
||||||
PacketReceive,
|
PacketReceive,
|
||||||
/// Couldn't decompress data.
|
/// Couldn't decompress data.
|
||||||
Decompress,
|
Decompress,
|
||||||
/// Couldn't create a socket connection.
|
/// Couldn't create a socket connection.
|
||||||
SocketConnect,
|
SocketConnect,
|
||||||
/// Couldn't bind a socket.
|
/// Couldn't bind a socket.
|
||||||
SocketBind,
|
SocketBind,
|
||||||
/// Invalid input.
|
/// Invalid input.
|
||||||
InvalidInput,
|
InvalidInput,
|
||||||
/// The server queried is not the queried game server.
|
/// The server queried is not the queried game server.
|
||||||
BadGame(String),
|
BadGame(String),
|
||||||
/// Couldn't automatically query.
|
/// Couldn't automatically query.
|
||||||
AutoQuery,
|
AutoQuery,
|
||||||
/// A protocol-defined expected format was not met.
|
/// A protocol-defined expected format was not met.
|
||||||
ProtocolFormat,
|
ProtocolFormat,
|
||||||
/// Couldn't cast a value to an enum.
|
/// Couldn't cast a value to an enum.
|
||||||
UnknownEnumCast,
|
UnknownEnumCast,
|
||||||
/// Couldn't parse a json string.
|
/// Couldn't parse a json string.
|
||||||
JsonParse,
|
JsonParse,
|
||||||
/// Couldn't parse a value.
|
/// Couldn't parse a value.
|
||||||
TypeParse,
|
TypeParse,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error for GDError {}
|
impl Error for GDError {}
|
||||||
|
|
||||||
impl fmt::Display for GDError {
|
impl fmt::Display for GDError {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self) }
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
// Testing Ok variant of the GDResult type
|
// Testing Ok variant of the GDResult type
|
||||||
#[test]
|
#[test]
|
||||||
fn test_gdresult_ok() {
|
fn test_gdresult_ok() {
|
||||||
let result: GDResult<u32> = Ok(42);
|
let result: GDResult<u32> = Ok(42);
|
||||||
assert_eq!(result.unwrap(), 42);
|
assert_eq!(result.unwrap(), 42);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Testing Err variant of the GDResult type
|
// Testing Err variant of the GDResult type
|
||||||
#[test]
|
#[test]
|
||||||
fn test_gdresult_err() {
|
fn test_gdresult_err() {
|
||||||
let result: GDResult<u32> = Err(GDError::InvalidInput);
|
let result: GDResult<u32> = Err(GDError::InvalidInput);
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Testing the Display trait for the GDError type
|
// Testing the Display trait for the GDError type
|
||||||
#[test]
|
#[test]
|
||||||
fn test_display() {
|
fn test_display() {
|
||||||
let error = GDError::PacketOverflow;
|
let error = GDError::PacketOverflow;
|
||||||
assert_eq!(format!("{}", error), "PacketOverflow");
|
assert_eq!(format!("{}", error), "PacketOverflow");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Testing the Error trait for the GDError type
|
// Testing the Error trait for the GDError type
|
||||||
#[test]
|
#[test]
|
||||||
fn test_error_trait() {
|
fn test_error_trait() {
|
||||||
let error = GDError::PacketBad;
|
let error = GDError::PacketBad;
|
||||||
assert!(error.source().is_none());
|
assert!(error.source().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Testing cloning the GDError type
|
// Testing cloning the GDError type
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cloning() {
|
fn test_cloning() {
|
||||||
let error = GDError::BadGame(String::from("MyGame"));
|
let error = GDError::BadGame(String::from("MyGame"));
|
||||||
let cloned_error = error.clone();
|
let cloned_error = error.clone();
|
||||||
assert_eq!(error, cloned_error);
|
assert_eq!(error, cloned_error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue