Resolve this value using the given `AuthContext`. - `Literal`: returned as-is. - `Field`: returned as-is (resolved at scan time by Data Plane). - `AuthRef`: resolved via `AuthContext::resolve_variable()`. - `AuthFunc`: resolved via `AuthContext` metadata (pre-computed). Returns `None` if an `AuthRef`/`AuthFunc` cannot be resolved.
(&self, auth: &AuthContext)
| 174 | /// |
| 175 | /// Returns `None` if an `AuthRef`/`AuthFunc` cannot be resolved. |
| 176 | pub fn resolve(&self, auth: &AuthContext) -> Option<serde_json::Value> { |
| 177 | match self { |
| 178 | Self::Literal(v) => Some(v.clone()), |
| 179 | Self::Field(_) => None, |
| 180 | Self::AuthRef(field) => auth.resolve_variable(field), |
| 181 | Self::AuthFunc { func, args } => { |
| 182 | // Functions are resolved via pre-computed metadata keys. |
| 183 | // e.g., scope_status('pro:all') → metadata["scope_status.pro:all"] |
| 184 | let arg = args.first().map(|s| s.as_str()).unwrap_or(""); |
| 185 | let key = format!("{func}.{arg}"); |
| 186 | auth.resolve_variable(&format!("metadata.{key}")) |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | /// Whether a policy is permissive (OR-combined) or restrictive (AND-combined). |
no test coverage detected