Skip to main content

Predicate

Struct Predicate 

Source
pub struct Predicate { /* private fields */ }
Expand description

One condition on a contract’s payload or on its row.

Implementations§

Source§

impl Predicate

Source

pub fn eq(path: impl IntoPath, value: impl Into<Value>) -> Self

A field of the payload equals value.

The comparison is JSON equality, so it is exact for every type: a Numeric that LF-JSON carries as "10.0" matches "10.0" and not 10.0, which is the distinction the encoding makes on purpose.

Source

pub fn not_eq(path: impl IntoPath, value: impl Into<Value>) -> Self

A field of the payload does not equal value — including when the field is absent.

Rendered as IS DISTINCT FROM rather than <>, and the difference is not pedantic here. <> against a missing path yields SQL NULL, so the row is excluded — and missing paths are the normal case for this crate, because qname deliberately matches on the package name so a query survives a Smart Contract Upgrade. A result set therefore mixes payloads of different versions with different field sets. Under <>, adding a field in v2 would silently drop every v1 contract from a not_eq on it, with no error and no warning.

Source

pub fn compare(path: impl IntoPath, op: Op, value: impl Into<Value>) -> Self

An ordered comparison on a field.

A contract whose payload lacks the field is not returned: there is no answer to “is the missing value greater than 10”. That is the right verdict, unlike for not_eq, but it is worth knowing when a query spans two versions of a template — use contains or a not_eq if the absent case should count.

A JSON number compares numerically and a JSON string compares as text. That distinction is not cosmetic: LF-JSON carries Int64 and Numeric as strings, so comparing an amount lexically would order "9" after "10". Pass a number to compare numerically — the cast is applied for you — and a string only where the field really is text.

Source

pub fn contains(value: impl Into<Value>) -> Self

The payload contains this JSON object (@>).

The predicate a GIN index on payload can serve.

Source

pub fn signatory(party: impl Into<String>) -> Self

The party is among the contract’s signatories.

Source

pub fn observer(party: impl Into<String>) -> Self

The party is among the contract’s observers.

Source

pub fn witness(party: impl Into<String>) -> Self

The party is among the parties that witnessed it.

Source

pub fn contract_id(id: impl Into<String>) -> Self

The contract id is exactly this.

Trait Implementations§

Source§

impl Clone for Predicate

Source§

fn clone(&self) -> Self

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 Predicate

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<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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more