MCPcopy Create free account
hub / github.com/aiscriptdev/aiscript / parse_directive

Method parse_directive

aiscript-directive/src/route/mod.rs:89–117  ·  view source on GitHub ↗
(&mut self, directive: Directive)

Source from the content-addressed store, hash-verified

87
88impl RouteAnnotation {
89 pub fn parse_directive(&mut self, directive: Directive) -> Result<(), String> {
90 match directive.name.as_str() {
91 "auth" | "basic_auth" => {
92 if matches!(self.auth, Auth::None) {
93 self.auth = Auth::from_directive(directive)?;
94 } else {
95 return Err("Duplicate auth directive".into());
96 }
97 }
98 "docs" => {
99 if self.docs.is_some() {
100 return Err("Duplicate @docs directive".into());
101 } else {
102 self.docs = Some(Docs::from_directive(directive)?);
103 }
104 }
105 "sso" => {
106 if let Some(Value::String(provider)) = directive.get_arg_value("provider") {
107 self.sso_provider = Some(SsoProvider::try_from(provider)?);
108 } else {
109 return Err("@sso required 'provider' argument.".into());
110 }
111 }
112 _ => {
113 return Err(format!("Invalid directive: @{}", directive.name));
114 }
115 }
116 Ok(())
117 }
118}

Callers

nothing calls this directly

Calls 2

get_arg_valueMethod · 0.80
as_strMethod · 0.45

Tested by

no test coverage detected