Implement bounded Binary LLSD codec
This commit is contained in:
@@ -16,9 +16,9 @@ use std::sync::{
|
||||
|
||||
pub trait Collection<T> {}
|
||||
|
||||
pub trait ReadWrite: std::io::Read + std::io::Write {}
|
||||
pub trait ReadWrite: std::io::Read + std::io::Write + std::io::Seek {}
|
||||
|
||||
impl<T: std::io::Read + std::io::Write> ReadWrite for T {}
|
||||
impl<T: std::io::Read + std::io::Write + std::io::Seek> ReadWrite for T {}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Object {
|
||||
|
||||
@@ -55,6 +55,13 @@ pub enum Error {
|
||||
InvalidOperation,
|
||||
/// An index or destination buffer boundary was exceeded.
|
||||
IndexOutOfRange,
|
||||
/// Structured input was malformed at a byte or character position.
|
||||
Parse {
|
||||
/// Zero-based offset at which validation failed.
|
||||
position: usize,
|
||||
/// Static parser context suitable for diagnostics and fuzz triage.
|
||||
context: &'static str,
|
||||
},
|
||||
/// An operation observed a requested cancellation.
|
||||
Cancelled,
|
||||
/// An HTTP request completed with an unsuccessful response.
|
||||
@@ -73,6 +80,7 @@ impl Error {
|
||||
| Self::Argument
|
||||
| Self::InvalidOperation
|
||||
| Self::IndexOutOfRange
|
||||
| Self::Parse { .. }
|
||||
| Self::Cancelled
|
||||
| Self::HttpRequest
|
||||
| Self::Socket => None,
|
||||
@@ -96,6 +104,9 @@ impl fmt::Display for Error {
|
||||
formatter.write_str("operation was invalid for the current state")
|
||||
}
|
||||
Self::IndexOutOfRange => formatter.write_str("index was out of range"),
|
||||
Self::Parse { position, context } => {
|
||||
write!(formatter, "parse error at offset {position}: {context}")
|
||||
}
|
||||
Self::Cancelled => formatter.write_str("operation was cancelled"),
|
||||
Self::HttpRequest => formatter.write_str("HTTP request failed"),
|
||||
Self::Socket => formatter.write_str("socket operation failed"),
|
||||
|
||||
Reference in New Issue
Block a user