pub struct ClassLevelPermissions { /* private fields */ }Expand description
Class-level permissions.
Constructed from the stored _metadata.class_permissions object or from a
POST/PUT /schemas body. Both paths keep Self::raw verbatim so that writing the block
back cannot drop a key parse-rust does not model.
No PartialEq, because Self::raw holds ParseValues and a derived comparison would
inherit that type’s float hazards. Compare the rendered JSON if two blocks need comparing.
Implementations§
Source§impl ClassLevelPermissions
impl ClassLevelPermissions
Sourcepub fn from_map(raw: ParseMap) -> Self
pub fn from_map(raw: ParseMap) -> Self
Parse a CLP block. Unknown keys are preserved in Self::raw and otherwise ignored;
rejecting them is the schema API’s job, not the model’s, because a block already in the
database has to be readable even if it would fail validation today.
Sourcepub fn raw(&self) -> &ParseMap
pub fn raw(&self) -> &ParseMap
The block exactly as it will be stored. Never derived from the parsed view.
Sourcepub fn op(&self, operation: Operation) -> Option<&OpPerm>
pub fn op(&self, operation: Operation) -> Option<&OpPerm>
The permission object for one operation.
None means unrestricted, not denied. Every caller has to spell that out; the reason
it cannot be unwrap_or_default() is the whole point of this module.
pub fn protected_fields(&self) -> &IndexMap<PfEntity, Vec<String>>
Sourcepub fn user_fields(&self, operation: Operation) -> &[String]
pub fn user_fields(&self, operation: Operation) -> &[String]
The class-wide pointer-field array for one operation, per
SchemaController.js:1425-1429.
pub fn read_user_fields(&self) -> &[String]
pub fn write_user_fields(&self) -> &[String]
Sourcepub fn default_acl(&self) -> Option<&ParseValue>
pub fn default_acl(&self) -> Option<&ParseValue>
The class’s declared default ACL, if it has one that upstream would stamp on a create.
None covers three cases that upstream’s condition collapses (RestWrite.js:379-384):
the ACL key is absent; its value is falsy, which is schema?.classLevelPermissions?.ACL
failing its own truthiness test; or it is exactly the public ACL, which upstream skips
because stamping {"*": {"read": true, "write": true}} on a row would only reproduce what
an absent ACL already means.
That last comparison is JSON.stringify equality upstream, so it is key-order
sensitive, and [is_the_public_acl] reproduces the ordering rather than comparing
structurally. A block whose keys arrived in the other order is not the public ACL as far
as upstream is concerned, and it gets stamped.
A truthy non-object is returned rather than filtered: upstream clones and assigns whatever
it finds, and the resulting ACL value is then lowered by the same rule any client-supplied
one is.
Sourcepub fn applicable_pointer_fields(&self, operation: Operation) -> Vec<String>
pub fn applicable_pointer_fields(&self, operation: Operation) -> Vec<String>
Every pointer field that applies to an operation, per-op first then class-wide, deduped.
Order is upstream’s (DatabaseController.js:1749-1764) and matters, because the clauses
are composed into an $or whose element order is observable in a compiled query.
Trait Implementations§
Source§impl Clone for ClassLevelPermissions
impl Clone for ClassLevelPermissions
Source§fn clone(&self) -> ClassLevelPermissions
fn clone(&self) -> ClassLevelPermissions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more