36 lines
1.0 KiB
Rust
36 lines
1.0 KiB
Rust
use crate::{
|
|
request_tokenizer::RequestTokenizer,
|
|
commands::{
|
|
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
|
ResponseParserError,
|
|
},
|
|
};
|
|
|
|
pub struct BinaryLimit;
|
|
|
|
impl Command for BinaryLimit {
|
|
type Request = u64;
|
|
type Response = ();
|
|
const COMMAND: &'static str = "binarylimit";
|
|
|
|
fn serialize_request(&self, request: Self::Request) -> String {
|
|
format!("{} {}", Self::COMMAND, request)
|
|
}
|
|
|
|
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
|
let limit = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
|
let limit = limit
|
|
.parse()
|
|
.map_err(|_| RequestParserError::SyntaxError(0, limit.to_string()))?;
|
|
debug_assert!(parts.next().is_none());
|
|
Ok((Request::BinaryLimit(limit), ""))
|
|
}
|
|
|
|
fn parse_response(
|
|
parts: ResponseAttributes<'_>,
|
|
) -> Result<Self::Response, ResponseParserError<'_>> {
|
|
debug_assert!(parts.is_empty());
|
|
Ok(())
|
|
}
|
|
}
|