-
Notifications
You must be signed in to change notification settings - Fork 44
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
11 changed files
with
117 additions
and
232 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,103 +1,52 @@ | ||
#![allow(unknown_lints)] | ||
#![allow(clippy::iter_without_into_iter)] | ||
use error_chain::error_chain; | ||
use thiserror::Error; | ||
|
||
error_chain! { | ||
types { | ||
BencodeParseError, BencodeParseErrorKind, BencodeParseResultExt, BencodeParseResult; | ||
} | ||
#[allow(clippy::module_name_repetitions)] | ||
#[derive(Error, Debug)] | ||
pub enum BencodeParseError { | ||
#[error("Incomplete Number Of Bytes At {pos}")] | ||
BytesEmpty { pos: usize }, | ||
|
||
errors { | ||
BytesEmpty { | ||
pos: usize | ||
} { | ||
description("Incomplete Number Of Bytes") | ||
display("Incomplete Number Of Bytes At {:?}", pos) | ||
} | ||
InvalidByte { | ||
pos: usize | ||
} { | ||
description("Invalid Byte Found") | ||
display("Invalid Byte Found At {:?}", pos) | ||
} | ||
InvalidIntNoDelimiter { | ||
pos: usize | ||
} { | ||
description("Invalid Integer Found With No Delimiter") | ||
display("Invalid Integer Found With No Delimiter At {:?}", pos) | ||
} | ||
InvalidIntNegativeZero { | ||
pos: usize | ||
} { | ||
description("Invalid Integer Found As Negative Zero") | ||
display("Invalid Integer Found As Negative Zero At {:?}", pos) | ||
} | ||
InvalidIntZeroPadding { | ||
pos: usize | ||
} { | ||
description("Invalid Integer Found With Zero Padding") | ||
display("Invalid Integer Found With Zero Padding At {:?}", pos) | ||
} | ||
InvalidIntParseError { | ||
pos: usize | ||
} { | ||
description("Invalid Integer Found To Fail Parsing") | ||
display("Invalid Integer Found To Fail Parsing At {:?}", pos) | ||
} | ||
InvalidKeyOrdering { | ||
pos: usize, | ||
key: Vec<u8> | ||
} { | ||
description("Invalid Dictionary Key Ordering Found") | ||
display("Invalid Dictionary Key Ordering Found At {:?} For Key {:?}", pos, key) | ||
} | ||
InvalidKeyDuplicates { | ||
pos: usize, | ||
key: Vec<u8> | ||
} { | ||
description("Invalid Dictionary Duplicate Keys Found") | ||
display("Invalid Dictionary Key Found At {:?} For Key {:?}", pos, key) | ||
} | ||
InvalidLengthNegative { | ||
pos: usize | ||
} { | ||
description("Invalid Byte Length Found As Negative") | ||
display("Invalid Byte Length Found As Negative At {:?}", pos) | ||
} | ||
InvalidLengthOverflow { | ||
pos: usize | ||
} { | ||
description("Invalid Byte Length Found To Overflow Buffer Length") | ||
display("Invalid Byte Length Found To Overflow Buffer Length At {:?}", pos) | ||
} | ||
InvalidRecursionExceeded { | ||
pos: usize, | ||
max: usize | ||
} { | ||
description("Invalid Recursion Limit Exceeded") | ||
display("Invalid Recursion Limit Exceeded At {:?} For Limit {:?}", pos, max) | ||
} | ||
} | ||
#[error("Invalid Byte Found At {pos}")] | ||
InvalidByte { pos: usize }, | ||
|
||
#[error("Invalid Integer Found With No Delimiter At {pos}")] | ||
InvalidIntNoDelimiter { pos: usize }, | ||
|
||
#[error("Invalid Integer Found As Negative Zero At {pos}")] | ||
InvalidIntNegativeZero { pos: usize }, | ||
|
||
#[error("Invalid Integer Found With Zero Padding At {pos}")] | ||
InvalidIntZeroPadding { pos: usize }, | ||
|
||
#[error("Invalid Integer Found To Fail Parsing At {pos}")] | ||
InvalidIntParseError { pos: usize }, | ||
|
||
#[error("Invalid Dictionary Key Ordering Found At {pos} For Key {key:?}")] | ||
InvalidKeyOrdering { pos: usize, key: Vec<u8> }, | ||
|
||
#[error("Invalid Dictionary Key Found At {pos} For Key {key:?}")] | ||
InvalidKeyDuplicates { pos: usize, key: Vec<u8> }, | ||
|
||
#[error("Invalid Byte Length Found As Negative At {pos}")] | ||
InvalidLengthNegative { pos: usize }, | ||
|
||
#[error("Invalid Byte Length Found To Overflow Buffer Length At {pos}")] | ||
InvalidLengthOverflow { pos: usize }, | ||
|
||
#[error("Invalid Recursion Limit Exceeded At {pos} For Limit {max}")] | ||
InvalidRecursionExceeded { pos: usize, max: usize }, | ||
} | ||
|
||
error_chain! { | ||
types { | ||
BencodeConvertError, BencodeConvertErrorKind, BencodeConvertResultExt, BencodeConvertResult; | ||
} | ||
pub type BencodeParseResult<T> = Result<T, BencodeParseError>; | ||
|
||
errors { | ||
MissingKey { | ||
key: Vec<u8> | ||
} { | ||
description("Missing Key In Bencode") | ||
display("Missing Key In Bencode For {:?}", key) | ||
} | ||
WrongType { | ||
key: Vec<u8>, | ||
expected_type: String | ||
} { | ||
description("Wrong Type In Bencode") | ||
display("Wrong Type In Bencode For {:?} Expected Type {}", key, expected_type) | ||
} | ||
} | ||
#[allow(clippy::module_name_repetitions)] | ||
#[derive(Error, Debug)] | ||
pub enum BencodeConvertError { | ||
#[error("Missing Key In Bencode For {key:?}")] | ||
MissingKey { key: Vec<u8> }, | ||
|
||
#[error("Wrong Type In Bencode For {key:?} Expected Type {expected_type}")] | ||
WrongType { key: Vec<u8>, expected_type: String }, | ||
} | ||
|
||
pub type BencodeConvertResult<T> = Result<T, BencodeConvertError>; |
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
Oops, something went wrong.