MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / set_for_kind

Method set_for_kind

nodedb-crdt/src/policy.rs:175–192  ·  view source on GitHub ↗

Set the policy for a specific constraint kind within a collection.

(
        &mut self,
        collection: &str,
        kind: &crate::constraint::ConstraintKind,
        policy: ConflictPolicy,
    )

Source from the content-addressed store, hash-verified

173
174 /// Set the policy for a specific constraint kind within a collection.
175 pub fn set_for_kind(
176 &mut self,
177 collection: &str,
178 kind: &crate::constraint::ConstraintKind,
179 policy: ConflictPolicy,
180 ) {
181 let mut coll_policy = self.get_owned(collection);
182 match kind {
183 crate::constraint::ConstraintKind::Unique => coll_policy.unique = policy,
184 crate::constraint::ConstraintKind::ForeignKey { .. }
185 | crate::constraint::ConstraintKind::BiTemporalFK { .. } => {
186 coll_policy.foreign_key = policy
187 }
188 crate::constraint::ConstraintKind::NotNull => coll_policy.not_null = policy,
189 crate::constraint::ConstraintKind::Check { .. } => coll_policy.check = policy,
190 }
191 self.set(collection, coll_policy);
192 }
193
194 /// Retrieve the policy for a collection as an owned value.
195 /// Returns the registered policy if found, otherwise returns the default (ephemeral).

Callers 1

registry_set_for_kindFunction · 0.80

Calls 2

get_ownedMethod · 0.80
setMethod · 0.45

Tested by 1

registry_set_for_kindFunction · 0.64