Skip to content

Commit

Permalink
added comments for Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
VictoremWinbringer committed Jan 4, 2019
1 parent fb785c8 commit 205d3d0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "victorem"
version = "0.6.0"
version = "0.7.0"
edition = "2018"
description = "UPD Game Server Framework"
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions src/business_logic_layer/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Filter {
self.id = data.get();
Ok(())
} else {
Err(Exception::NotValidIdError)
Err(Exception::NotOrderedPacketError)
}
}
}
Expand Down Expand Up @@ -93,7 +93,7 @@ impl<T: IWithId> Arranger<T> {
}
self.clear_if_overflows();
if self.received.contains(&data.get()) {
Err(Exception::NotValidIdError)
Err(Exception::NotOrderedPacketError)
} else {
self.received.push(data.get());
self.packets.entry(data.get()).or_insert(data);
Expand Down
2 changes: 1 addition & 1 deletion src/business_logic_layer/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl ProtocolChecker {
if data.get() == PROTOCOL_ID {
Ok(())
} else {
Err(Exception::BadProtocolVersion)
Err(Exception::NotValidIdError)
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,23 @@ pub struct StatePacket {
}

#[derive(Debug)]
///Error in framework
pub enum Exception {
///Error on send or recv from UDP
/// If it kind is [`std::io::ErrorKind::WouldBlock`] then retry again.
IoError(io::Error),
/// Different lib version on client and server.
/// You must update client and server.
BadProtocolVersion,
///Error on serialize or deserialize
BincodeError(bincode::Error),
/// Not ordered command or state come by this reason it was skipped.
/// Maybe it is duplicated.
/// Retry again.
NotOrderedPacketError,
///Packet not from this lib.
/// Lib ignoring it.
/// Retry again.
NotValidIdError,
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl ClientSocket {

///Reads data from server.
/// Don't block current thread.
/// Return [`Exception`] with [`io::ErrorKind::WouldBlock`] if there is no data available.
/// Return [`Exception`] with [`std::io::ErrorKind::WouldBlock`] if there is no data available.
///Data ordered and without some guarantees.
pub fn recv(&mut self) -> Result<Vec<u8>, Exception> {
let state = self.socket.read()?;
Expand Down

0 comments on commit 205d3d0

Please sign in to comment.