-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,236 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
/target | ||
configuration.toml | ||
features.toml |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
use crate::{ | ||
entity::player::GameMode, | ||
protocol::{ClientPacket, VarInt}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use super::Tag; | ||
use serde::{de, ser}; | ||
use std::{fmt, fmt::Display, num::TryFromIntError}; | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
pub enum Error { | ||
Message(String), | ||
Eof, | ||
|
||
TryFromInt(TryFromIntError), | ||
ListType(Tag, Tag), | ||
MapKey(Tag), | ||
CannotSerializeNone, | ||
Enum, | ||
} | ||
|
||
pub type Result<T> = std::result::Result<T, Error>; | ||
|
||
impl ser::Error for Error { | ||
fn custom<T: Display>(msg: T) -> Self { | ||
Error::Message(msg.to_string()) | ||
} | ||
} | ||
|
||
impl de::Error for Error { | ||
fn custom<T: Display>(msg: T) -> Self { | ||
Error::Message(msg.to_string()) | ||
} | ||
} | ||
|
||
impl Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match self { | ||
Error::Message(msg) => write!(f, "{msg}"), | ||
Error::Eof => write!(f, "unexpected end of input"), | ||
Error::TryFromInt(e) => write!(f, "invalid integer: {e}"), | ||
Error::ListType(expected, got) => { | ||
write!(f, "expected type in list: {expected:?}, got: {got:?}") | ||
} | ||
Error::MapKey(got) => { | ||
write!(f, "expected a string for map key, got: {got:?}") | ||
} | ||
Error::CannotSerializeNone => { | ||
write!( | ||
f, | ||
"cannot serialize `None` or `()` (use `#[serde(skip_serializing_if = \"Option::is_none\")]`)" | ||
) | ||
} | ||
Error::Enum => { | ||
write!(f, "enums are not supported") | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl std::error::Error for Error {} |
Oops, something went wrong.