pub struct TypedDomainRecordRef<T>where
T: DomainRecordType,{ /* private fields */ }Expand description
Typed façade over a stable application-defined record identity.
Its serialized representation is exactly the wrapped DomainRecordRef;
the marker exists only at compile time.
Implementations§
Source§impl<T> TypedDomainRecordRef<T>where
T: DomainRecordType,
impl<T> TypedDomainRecordRef<T>where
T: DomainRecordType,
Sourcepub fn new(id: impl Into<String>) -> TypedDomainRecordRef<T>
pub fn new(id: impl Into<String>) -> TypedDomainRecordRef<T>
Sourcepub const fn as_untyped(&self) -> &DomainRecordRef
pub const fn as_untyped(&self) -> &DomainRecordRef
Examples found in repository?
examples/governance_transition.rs (line 377)
366fn audit_order(
367 view: &SimulationView<'_>,
368 context: &BoundaryContext,
369) -> Result<BoundaryProposal, CanwuError> {
370 if owned_order_ingress(view, context, CENTRAL_PLUGIN, ISSUE_INGRESS)?.is_some() {
371 return Ok(BoundaryProposal::default());
372 }
373 let order = order_payload(view)?;
374 for (label, reference, expected_plugin, expected_system) in [
375 (
376 "treasury",
377 treasury_reference().as_untyped(),
378 TREASURY_PLUGIN,
379 "prepare-treasury",
380 ),
381 (
382 "county",
383 county_reference().as_untyped(),
384 COUNTY_PLUGIN,
385 "prepare-county",
386 ),
387 ] {
388 let record = view.domain_record(reference)?.ok_or_else(|| {
389 CanwuError::new(
390 ErrorCode::InvalidBoundary,
391 format!("central audit is missing the {label} relief disposition"),
392 )
393 })?;
394 let expected_hash = action_hash(600)?;
395 validate_order(&order, expected_system, expected_plugin, &expected_hash)?;
396 let actual_hash = canonical_hash(ACTION_HASH_DOMAIN, &record.payload)?;
397 if record.version != 1
398 || !record.is_active()
399 || record.owner != expected_plugin
400 || actual_hash != expected_hash
401 || record.payload != json!({"status": "committed", "grain_units": 600})
402 {
403 return Err(CanwuError::new(
404 ErrorCode::InvalidBoundary,
405 format!("central audit found an invalid {label} disposition"),
406 ));
407 }
408 }
409 Ok(BoundaryProposal::default())
410}pub fn into_untyped(self) -> DomainRecordRef
Sourcepub fn from_untyped(
reference: DomainRecordRef,
) -> Result<TypedDomainRecordRef<T>, DomainRecordRef>
pub fn from_untyped( reference: DomainRecordRef, ) -> Result<TypedDomainRecordRef<T>, DomainRecordRef>
Converts an untyped reference when its namespaced kind matches T.
§Errors
Returns the original reference when it belongs to another kind.
pub fn id(&self) -> &str
Trait Implementations§
Source§impl<T> Clone for TypedDomainRecordRef<T>where
T: DomainRecordType,
impl<T> Clone for TypedDomainRecordRef<T>where
T: DomainRecordType,
Source§fn clone(&self) -> TypedDomainRecordRef<T>
fn clone(&self) -> TypedDomainRecordRef<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for TypedDomainRecordRef<T>where
T: DomainRecordType,
impl<T> Debug for TypedDomainRecordRef<T>where
T: DomainRecordType,
Source§impl<'de, T> Deserialize<'de> for TypedDomainRecordRef<T>where
T: DomainRecordType,
impl<'de, T> Deserialize<'de> for TypedDomainRecordRef<T>where
T: DomainRecordType,
Source§fn deserialize<D>(
deserializer: D,
) -> Result<TypedDomainRecordRef<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<TypedDomainRecordRef<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> Display for TypedDomainRecordRef<T>where
T: DomainRecordType,
impl<T> Display for TypedDomainRecordRef<T>where
T: DomainRecordType,
impl<T> Eq for TypedDomainRecordRef<T>where
T: DomainRecordType,
Source§impl<T> From<TypedDomainRecordRef<T>> for DomainRecordRefwhere
T: DomainRecordType,
impl<T> From<TypedDomainRecordRef<T>> for DomainRecordRefwhere
T: DomainRecordType,
Source§fn from(reference: TypedDomainRecordRef<T>) -> DomainRecordRef
fn from(reference: TypedDomainRecordRef<T>) -> DomainRecordRef
Converts to this type from the input type.
Source§impl<T> From<TypedDomainRecordRef<T>> for EntityRefwhere
T: DomainEntityType,
impl<T> From<TypedDomainRecordRef<T>> for EntityRefwhere
T: DomainEntityType,
Source§fn from(reference: TypedDomainRecordRef<T>) -> EntityRef
fn from(reference: TypedDomainRecordRef<T>) -> EntityRef
Converts to this type from the input type.
Source§impl<T> Hash for TypedDomainRecordRef<T>where
T: DomainRecordType,
impl<T> Hash for TypedDomainRecordRef<T>where
T: DomainRecordType,
Source§impl<T> Ord for TypedDomainRecordRef<T>where
T: DomainRecordType,
impl<T> Ord for TypedDomainRecordRef<T>where
T: DomainRecordType,
Source§fn cmp(&self, other: &TypedDomainRecordRef<T>) -> Ordering
fn cmp(&self, other: &TypedDomainRecordRef<T>) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl<T> PartialEq for TypedDomainRecordRef<T>where
T: DomainRecordType,
impl<T> PartialEq for TypedDomainRecordRef<T>where
T: DomainRecordType,
Source§impl<T> PartialOrd for TypedDomainRecordRef<T>where
T: DomainRecordType,
impl<T> PartialOrd for TypedDomainRecordRef<T>where
T: DomainRecordType,
Source§impl<T> Serialize for TypedDomainRecordRef<T>where
T: DomainRecordType,
impl<T> Serialize for TypedDomainRecordRef<T>where
T: DomainRecordType,
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl<T> Freeze for TypedDomainRecordRef<T>
impl<T> RefUnwindSafe for TypedDomainRecordRef<T>
impl<T> Send for TypedDomainRecordRef<T>
impl<T> Sync for TypedDomainRecordRef<T>
impl<T> Unpin for TypedDomainRecordRef<T>
impl<T> UnsafeUnpin for TypedDomainRecordRef<T>
impl<T> UnwindSafe for TypedDomainRecordRef<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more