Implement some more commands
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||
},
|
||||
common::OneOrRange,
|
||||
Request,
|
||||
};
|
||||
|
||||
pub struct Delete;
|
||||
|
||||
impl Command for Delete {
|
||||
type Response = ();
|
||||
const COMMAND: &'static str = "delete";
|
||||
|
||||
fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
|
||||
let pos_or_range = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let one_or_range = OneOrRange::from_str(pos_or_range)
|
||||
.map_err(|_| RequestParserError::SyntaxError(0, pos_or_range.to_string()))?;
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Delete(one_or_range), ""))
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
parts: ResponseAttributes<'_>,
|
||||
) -> Result<Self::Response, ResponseParserError> {
|
||||
debug_assert!(parts.is_empty());
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user