Skip to main content

StrColExt

Trait StrColExt 

Source
pub trait StrColExt<T> {
    // Required methods
    fn lower(&self) -> ColExpr<T>;
    fn upper(&self) -> ColExpr<T>;
    fn length(&self) -> ColExpr<T>;
    fn trim(&self) -> ColExpr<T>;
    fn coalesce<V: Into<Value>>(&self, default: V) -> ColExpr<T>;
    fn concat<V: Into<Value>>(&self, suffix: V) -> ColExpr<T>;
}
Expand description

String-function helpers — lower(), upper(), length(), trim(), coalesce(), concat(). Implemented for both StrCol<T> and NullableStrCol<T> so the extension methods work whether the column is String or Option<String>.

Each returns a ColExpr; chain a comparison (.eq / .ne / .lt …) to produce a Predicate<T> for filter / exclude. All six render identically on SQLite and Postgres (TRIM, COALESCE are standard SQL; || is the standard concatenation operator both backends accept).

Required Methods§

Source

fn lower(&self) -> ColExpr<T>

LOWER(col) — case-insensitive comparison primitive.

Source

fn upper(&self) -> ColExpr<T>

UPPER(col).

Source

fn length(&self) -> ColExpr<T>

LENGTH(col) — character count of the stored value.

Source

fn trim(&self) -> ColExpr<T>

TRIM(col) — strip leading/trailing whitespace before comparing, so name.trim().eq("ada") matches a stored " ada ".

Source

fn coalesce<V: Into<Value>>(&self, default: V) -> ColExpr<T>

COALESCE(col, default) — substitute default when the column is NULL, so a nullable column compares as the fallback. Mostly paired with NullableStrCol.

Source

fn concat<V: Into<Value>>(&self, suffix: V) -> ColExpr<T>

col || suffix — append suffix (the standard SQL concatenation operator, which both backends accept) before comparing.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> StrColExt<T> for NullableStrCol<T>

Source§

impl<T> StrColExt<T> for StrCol<T>