pub struct Predicate { /* private fields */ }Expand description
One condition on a contract’s payload or on its row.
Implementations§
Source§impl Predicate
impl Predicate
Sourcepub fn eq(path: impl IntoPath, value: impl Into<Value>) -> Self
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.
Sourcepub fn not_eq(path: impl IntoPath, value: impl Into<Value>) -> Self
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.
Sourcepub fn compare(path: impl IntoPath, op: Op, value: impl Into<Value>) -> Self
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.
Sourcepub fn contains(value: impl Into<Value>) -> Self
pub fn contains(value: impl Into<Value>) -> Self
The payload contains this JSON object (@>).
The predicate a GIN index on payload can serve.
Sourcepub fn signatory(party: impl Into<String>) -> Self
pub fn signatory(party: impl Into<String>) -> Self
The party is among the contract’s signatories.
Sourcepub fn witness(party: impl Into<String>) -> Self
pub fn witness(party: impl Into<String>) -> Self
The party is among the parties that witnessed it.
Sourcepub fn contract_id(id: impl Into<String>) -> Self
pub fn contract_id(id: impl Into<String>) -> Self
The contract id is exactly this.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Predicate
impl RefUnwindSafe for Predicate
impl Send for Predicate
impl Sync for Predicate
impl Unpin for Predicate
impl UnsafeUnpin for Predicate
impl UnwindSafe for Predicate
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request