pub enum Visibility {
And {
and: Vec<Visibility>,
},
Or {
or: Vec<Visibility>,
},
Not {
not: Box<Visibility>,
},
Condition(VisibilityCondition),
}Expand description
Visibility rule with logical composition support.
Uses #[serde(untagged)] to support clean JSON:
- Simple:
{"path": "/data/users", "operator": "not_empty"} - Compound:
{"and": [...]} - Nested:
{"not": {"path": ..., "operator": ...}}
Deserialize is hand-rolled (not derived) to produce a shape-listing error message when an unknown JSON object is encountered. The derive-based untagged impl emits “data did not match any variant of untagged enum Visibility” — useless for debugging. See D-19/F5.
Variants§
And
Fields
and: Vec<Visibility>Or
Fields
or: Vec<Visibility>Not
Fields
not: Box<Visibility>Condition(VisibilityCondition)
Implementations§
Source§impl Visibility
impl Visibility
Sourcepub fn evaluate(&self, data: &Value) -> bool
pub fn evaluate(&self, data: &Value) -> bool
Evaluates this visibility rule against handler data.
Infallible: malformed conditions, missing paths, and type mismatches all
resolve to false (visibility hides the element) without panicking. This
is the contract Phase 116’s renderer relies on per CONTEXT D-13.
Edge cases (per Phase 116 RESEARCH §“Visibility … TO BE ADDED” and Assumptions Log A1):
Eqagainst a missing path →false(no value to compare).NotEqagainst a missing path →true(no value, so it’s “not equal” to anything).- Numeric comparators (
Gt/Lt/Gte/Lte) against non-numeric or missing →false. Containson a scalar value →false.NotEmpty/Emptytreat numbers and booleans as non-empty.
Visibility is a presentation-layer concern only. Never treat
visible: false as a server-side access check — enforce authorization
in the routing/handler layer, not here.
Trait Implementations§
Source§impl Clone for Visibility
impl Clone for Visibility
Source§fn clone(&self) -> Visibility
fn clone(&self) -> Visibility
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Visibility
impl Debug for Visibility
Source§impl<'de> Deserialize<'de> for Visibility
impl<'de> Deserialize<'de> for Visibility
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Source§impl JsonSchema for Visibility
impl JsonSchema for Visibility
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for Visibility
impl PartialEq for Visibility
Source§fn eq(&self, other: &Visibility) -> bool
fn eq(&self, other: &Visibility) -> bool
self and other values to be equal, and is used by ==.