Module zero_copy

Module zero_copy 

Source
Expand description

Zero-copy types for performance-critical operations.

This module provides borrowed/reference-based versions of common types to avoid unnecessary allocations in hot paths.

§Types

Owned TypeZero-Copy TypeUse Case
JsonPathJsonPathRef<'a>JSON path queries with borrowed strings
WindowSpecWindowSpecRef<'a>Window function specs with borrowed columns
CteCteRef<'a>CTE definitions with borrowed column slices

§Performance Benefits

  • Avoids String allocations when using string literals or borrowed data
  • Reduces memory copies in query building hot paths
  • Enables zero-copy deserialization patterns

§Example

use prax_query::zero_copy::{JsonPathRef, PathSegmentRef, WindowSpecRef};
use prax_query::sql::DatabaseType;

// Zero-copy JSON path - no allocations!
let path = JsonPathRef::new("metadata")
    .field("role")
    .field("permissions");

let sql = path.to_sql(DatabaseType::PostgreSQL);

// Zero-copy window spec
let spec = WindowSpecRef::new()
    .partition_by(&["dept", "team"])
    .order_by_asc("salary");

let sql = spec.to_sql(DatabaseType::PostgreSQL);

Structs§

CteRef
A zero-copy CTE definition that accepts column slices.
FrameRef
A frame clause for window specifications.
JsonPathRef
A zero-copy JSON path expression that borrows strings where possible.
WindowSpecRef
A zero-copy window specification using borrowed column references.
WithClauseRef
A builder for WITH clauses using zero-copy CTEs.

Enums§

FrameBoundRef
Frame bound specification.
FrameTypeRef
Frame type for window functions.
PathSegmentRef
A segment in a zero-copy JSON path.