valence_command/parsers/
entity_anchor.rs
1use super::Parser;
2use crate::parsers::{CommandArg, CommandArgParseError, ParseInput};
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
5pub enum EntityAnchor {
6 #[default]
7 Eyes,
8 Feet,
9}
10
11impl CommandArg for EntityAnchor {
12 fn parse_arg(input: &mut ParseInput) -> Result<Self, CommandArgParseError> {
13 input.skip_whitespace();
14 if input.match_next("eyes") {
15 Ok(EntityAnchor::Eyes)
16 } else if input.match_next("feet") {
17 Ok(EntityAnchor::Feet)
18 } else {
19 Err(CommandArgParseError::InvalidArgument {
20 expected: "entity_anchor".to_owned(),
21 got: "not a valid entity anchor".to_owned(),
22 })
23 }
24 }
25
26 fn display() -> Parser {
27 Parser::EntityAnchor
28 }
29}