Skip to main content

BindExpr

Enum BindExpr 

Source
pub enum BindExpr {
Show 42 variants Term(Term), Add(Box<BindExpr>, Box<BindExpr>), Sub(Box<BindExpr>, Box<BindExpr>), Mul(Box<BindExpr>, Box<BindExpr>), Div(Box<BindExpr>, Box<BindExpr>), Neg(Box<BindExpr>), Abs(Box<BindExpr>), Ceil(Box<BindExpr>), Floor(Box<BindExpr>), Round(Box<BindExpr>), Str(Box<BindExpr>), StrLen(Box<BindExpr>), UCase(Box<BindExpr>), LCase(Box<BindExpr>), Concat(Vec<BindExpr>), SubStr { value: Box<BindExpr>, start: Box<BindExpr>, len: Option<Box<BindExpr>>, }, StrBefore(Box<BindExpr>, Box<BindExpr>), StrAfter(Box<BindExpr>, Box<BindExpr>), Replace { value: Box<BindExpr>, pattern: Box<BindExpr>, replacement: Box<BindExpr>, flags: Option<Box<BindExpr>>, }, EncodeForUri(Box<BindExpr>), Md5(Box<BindExpr>), Sha1(Box<BindExpr>), Sha256(Box<BindExpr>), Sha384(Box<BindExpr>), Sha512(Box<BindExpr>), CastInteger(Box<BindExpr>), CastDecimal(Box<BindExpr>), CastDouble(Box<BindExpr>), CastFloat(Box<BindExpr>), CastString(Box<BindExpr>), Year(Box<BindExpr>), Month(Box<BindExpr>), Day(Box<BindExpr>), Hours(Box<BindExpr>), Minutes(Box<BindExpr>), Seconds(Box<BindExpr>), Timezone(Box<BindExpr>), Tz(Box<BindExpr>), Now, Lang(Box<BindExpr>), Iri(Box<BindExpr>), BNode(Box<BindExpr>),
}
Expand description

Expression carried by a Literal::Bind body literal.

BindExpr covers identity assignment plus integer arithmetic over ConstantSymbols whose lexical form parses as an i64. Operands may be Term::Variables (resolved against the current candidate binding) or Term::Constants.

Numeric semantics: arithmetic operands must parse as base-10 i64; otherwise the expression is undefined for the current binding and the evaluator drops the candidate. SPARQL numeric promotion (integer → decimal → float → double), xsd:decimal arithmetic, and the remaining SPARQL string / date / IRI builtins inside BIND are tracked as extension follow-ups under the rule validation specification.

String semantics: Str, StrLen, UCase, LCase, and Concat operate on the lexical form of literals (when the operand classifies as a literal under the evaluator’s RDF term classification) or on the constant string itself otherwise. The result of Str / UCase / LCase / Concat is encoded as a plain literal (empty datatype IRI); the result of StrLen is an xsd:integer literal so subsequent arithmetic can consume it without re-parsing.

Variants§

§

Term(Term)

Identity — bind the variable to the term itself (typically useful in the form BIND(?x AS ?y) for renaming).

§

Add(Box<BindExpr>, Box<BindExpr>)

SPARQL +. Type-polymorphic in the forward engine: numeric addition (over the integer → decimal → float → double promotion lattice) or xsd:dateTime + xsd:dayTimeDuration → xsd:dateTime. Operand pairs that don’t match either shape drop the candidate.

§

Sub(Box<BindExpr>, Box<BindExpr>)

SPARQL -. Type-polymorphic in the forward engine: numeric subtraction, xsd:dateTime - xsd:dayTimeDuration → xsd:dateTime (backward shift), or xsd:dateTime - xsd:dateTime → xsd:dayTimeDuration (the duration between two instants).

§

Mul(Box<BindExpr>, Box<BindExpr>)

Integer multiplication over i64.

§

Div(Box<BindExpr>, Box<BindExpr>)

Integer division (truncated) over i64. Division by zero is undefined and drops the candidate binding.

§

Neg(Box<BindExpr>)

Integer negation over i64.

§

Abs(Box<BindExpr>)

ABS(numeric) — absolute value, preserving the input’s SPARQL numeric datatype (integer → integer, decimal → decimal, float → float, double → double). A non-numeric operand drops the candidate binding.

§

Ceil(Box<BindExpr>)

CEIL(numeric) — smallest integer-valued result ≥ the input, preserving the input’s SPARQL numeric datatype. For an xsd:integer input the value passes through unchanged. For an xsd:decimal input the lexical form is the integer ceiling (no fractional component) but the datatype stays xsd:decimal per SPARQL 1.1 §17.4.4.4.

§

Floor(Box<BindExpr>)

FLOOR(numeric) — largest integer-valued result ≤ the input, preserving the input’s SPARQL numeric datatype. Symmetric to Self::Ceil.

§

Round(Box<BindExpr>)

ROUND(numeric) — round half toward positive infinity (XPath fn:round semantics, matching SPARQL 1.1 §17.4.4.6). Preserves the input’s SPARQL numeric datatype.

§

Str(Box<BindExpr>)

STR(?x) — lexical form. For literals returns a plain literal carrying the lex; for IRIs / blank nodes returns the constant string as a plain literal.

§

StrLen(Box<BindExpr>)

STRLEN(?x) — number of Unicode scalar values in the lexical form. Result is an xsd:integer literal.

§

UCase(Box<BindExpr>)

UCASE(?x) — uppercase the lexical form (Unicode-aware).

§

LCase(Box<BindExpr>)

LCASE(?x) — lowercase the lexical form (Unicode-aware).

§

Concat(Vec<BindExpr>)

CONCAT(?a, ?b, ...) — concatenate the lexical forms of each argument and return a plain literal.

§

SubStr

SUBSTR(value, start) or SUBSTR(value, start, len) — 1-based substring extraction over Unicode scalar values. Negative or zero start clamps to position 1; start past the end of the value yields the empty plain literal; an over-long len is clamped to “until end”. Mirrors the SPARQL 1.1 semantics for SUBSTR.

Fields

§value: Box<BindExpr>

The string-valued source expression.

§start: Box<BindExpr>

1-based start position, in Unicode scalars.

§len: Option<Box<BindExpr>>

Optional length, in Unicode scalars. None means “until end”.

§

StrBefore(Box<BindExpr>, Box<BindExpr>)

STRBEFORE(value, needle) — substring of value before the first occurrence of needle. Per SPARQL 1.1: empty plain literal when needle is not found, and an empty plain literal when needle itself is empty.

§

StrAfter(Box<BindExpr>, Box<BindExpr>)

STRAFTER(value, needle) — substring of value after the first occurrence of needle. Per SPARQL 1.1: empty plain literal when needle is not found, and the full value when needle is empty.

§

Replace

REPLACE(value, pattern, replacement, flags?) — replace every match of the regex pattern (compiled with the same SPARQL flag subset as BuiltinFilter::RegexMatch — i, m, s, x) with replacement. A malformed pattern, an unsupported flag, or any unbound variable drops the candidate binding.

Fields

§value: Box<BindExpr>

The string-valued source expression.

§pattern: Box<BindExpr>

The regex pattern.

§replacement: Box<BindExpr>

The replacement template (back-references such as $1 follow the regex crate’s syntax).

§flags: Option<Box<BindExpr>>

Optional flags string (e.g. "i", "im").

§

EncodeForUri(Box<BindExpr>)

ENCODE_FOR_URI(value) — percent-encode every code point outside the RFC 3986 unreserved set (ALPHA / DIGIT / - / . / _ / ~) into its UTF-8-byte %HH form.

§

Md5(Box<BindExpr>)

MD5(value) — RFC 1321 message digest of the lexical form’s UTF-8 bytes. Result is a plain literal carrying the lowercase hex digest.

§

Sha1(Box<BindExpr>)

SHA1(value) — FIPS 180-4 SHA-1 digest. Result is a plain literal carrying the lowercase hex digest.

§

Sha256(Box<BindExpr>)

SHA256(value) — FIPS 180-4 SHA-256 digest.

§

Sha384(Box<BindExpr>)

SHA384(value) — FIPS 180-4 SHA-384 digest.

§

Sha512(Box<BindExpr>)

SHA512(value) — FIPS 180-4 SHA-512 digest.

§

CastInteger(Box<BindExpr>)

xsd:integer(value) — parse the lexical form as base-10 i64. Emits an xsd:integer literal. A parse failure drops the candidate binding.

§

CastDecimal(Box<BindExpr>)

xsd:decimal(value) — parse the lexical form as a SPARQL decimal (delegates to bigdecimal::BigDecimal::from_str). Emits an xsd:decimal literal carrying the parsed canonical form. A parse failure drops the candidate.

§

CastDouble(Box<BindExpr>)

xsd:double(value) — parse the lexical form as a base-10 f64. Emits an xsd:double literal. A parse failure or non-finite value drops the candidate.

§

CastFloat(Box<BindExpr>)

xsd:float(value) — parse the lexical form as a base-10 f32. Emits an xsd:float literal. A parse failure or non-finite value drops the candidate.

§

CastString(Box<BindExpr>)

xsd:string(value) — emit the lexical form as an xsd:string-typed literal. Always succeeds.

§

Year(Box<BindExpr>)

YEAR(dateTime) — extract the year component as an xsd:integer literal. The argument’s lexical form must parse as xsd:dateTime; otherwise the candidate drops.

§

Month(Box<BindExpr>)

MONTH(dateTime) — month component (1–12) as an xsd:integer literal.

§

Day(Box<BindExpr>)

DAY(dateTime) — day-of-month (1–31) as an xsd:integer literal.

§

Hours(Box<BindExpr>)

HOURS(dateTime) — hour-of-day (0–23) as an xsd:integer literal.

§

Minutes(Box<BindExpr>)

MINUTES(dateTime) — minute-of-hour (0–59) as an xsd:integer literal.

§

Seconds(Box<BindExpr>)

SECONDS(dateTime) — second-of-minute (including the fractional part) as an xsd:decimal literal.

§

Timezone(Box<BindExpr>)

TIMEZONE(dateTime) — UTC offset as an xsd:dayTimeDuration literal (e.g. "PT5H", "-PT5H", "PT0S"). The candidate drops when the input has no timezone designator (per SPARQL spec — TIMEZONE is an error in that case).

§

Tz(Box<BindExpr>)

TZ(dateTime) — UTC offset as an xsd:string literal: "Z" for UTC, "+05:00" / "-08:00" etc. for offset designators, and the empty string when the input has no timezone.

§

Now

NOW() — current xsd:dateTime (UTC). The literal returned is fixed at evaluation time; SPARQL guarantees it stays constant across one query, but this Datalog BIND evaluates the expression once per candidate binding, which is consistent with SPARQL’s stability requirement (every reference under one rule firing sees the same instant).

§

Lang(Box<BindExpr>)

LANG(?lit) — extract the language tag from a language-tagged literal. Returns a plain xsd:string literal carrying the tag (lower-cased per SPARQL 1.1 canonicalization), or the empty string for non-language- tagged literals. Drops the candidate when the operand is not a literal (IRIs / blank nodes — SPARQL “type error → no result”).

§

Iri(Box<BindExpr>)

IRI(?str) — construct an IRI term from a string-valued expression. If the operand is already an IRI it passes through unchanged (SPARQL 1.1 §17.4.2.8). Drops the candidate for blank-node operands.

§

BNode(Box<BindExpr>)

BNODE(?seed) — construct a blank node deterministically from a string seed. Multiple calls with the same seed yield the same blank-node label, which matches SPARQL 1.1 §17.4.2.4 “two calls with the same string return the same blank node within one solution sequence” and gives rules reproducible blank-node identity across firings. The 0-arg BNODE() / UUID() / STRUUID() forms remain non-deterministic and stay out of BindExpr (they require the extension skolemization track).

Implementations§

Source§

impl BindExpr

Source

pub fn variables(&self) -> BTreeSet<VariableSymbol>

All variables referenced anywhere inside the expression.

Trait Implementations§

Source§

impl Clone for BindExpr

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 BindExpr

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for BindExpr

Source§

impl Hash for BindExpr

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for BindExpr

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BindExpr

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, 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> 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.