Skip to main content

ClassLevelPermissions

Struct ClassLevelPermissions 

Source
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

Source

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.

Source

pub fn raw(&self) -> &ParseMap

The block exactly as it will be stored. Never derived from the parsed view.

Source

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.

Source

pub fn protected_fields(&self) -> &IndexMap<PfEntity, Vec<String>>

Source

pub fn user_fields(&self, operation: Operation) -> &[String]

The class-wide pointer-field array for one operation, per SchemaController.js:1425-1429.

Source

pub fn read_user_fields(&self) -> &[String]

Source

pub fn write_user_fields(&self) -> &[String]

Source

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.

Source

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

Source§

fn clone(&self) -> ClassLevelPermissions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClassLevelPermissions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V