pub struct OrderByField {
pub column: Cow<'static, str>,
pub order: SortOrder,
pub nulls: Option<NullsOrder>,
}Expand description
Order by specification for a single field.
Fields§
§column: Cow<'static, str>The column name to order by.
order: SortOrderThe sort order.
nulls: Option<NullsOrder>Null handling (optional).
Implementations§
Source§impl OrderByField
impl OrderByField
Sourcepub fn new(column: impl Into<Cow<'static, str>>, order: SortOrder) -> Self
pub fn new(column: impl Into<Cow<'static, str>>, order: SortOrder) -> Self
Create a new order by field.
Sourcepub const fn new_static(column: &'static str, order: SortOrder) -> Self
pub const fn new_static(column: &'static str, order: SortOrder) -> Self
Create a new order by field with a static column name (zero allocation).
Sourcepub fn nulls(self, nulls: NullsOrder) -> Self
pub fn nulls(self, nulls: NullsOrder) -> Self
Set null handling.
Sourcepub const fn asc_static(column: &'static str) -> Self
pub const fn asc_static(column: &'static str) -> Self
Create an ascending order with a static column name (zero allocation).
Sourcepub const fn desc_static(column: &'static str) -> Self
pub const fn desc_static(column: &'static str) -> Self
Create a descending order with a static column name (zero allocation).
Sourcepub fn to_sql(&self) -> String
pub fn to_sql(&self) -> String
Generate the SQL for this order by field.
Optimized to write directly to a pre-sized buffer.
Sourcepub fn write_sql(&self, buffer: &mut String)
pub fn write_sql(&self, buffer: &mut String)
Write the SQL directly to a buffer (zero allocation).
§Examples
use prax_query::types::OrderByField;
let field = OrderByField::desc("created_at");
let mut buffer = String::with_capacity(64);
buffer.push_str("ORDER BY ");
field.write_sql(&mut buffer);
assert_eq!(buffer, "ORDER BY created_at DESC");Sourcepub fn estimated_len(&self) -> usize
pub fn estimated_len(&self) -> usize
Get the estimated SQL length for capacity planning.
Trait Implementations§
Source§impl Clone for OrderByField
impl Clone for OrderByField
Source§fn clone(&self) -> OrderByField
fn clone(&self) -> OrderByField
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OrderByField
impl Debug for OrderByField
Source§impl From<OrderByField> for OrderBy
impl From<OrderByField> for OrderBy
Source§fn from(field: OrderByField) -> Self
fn from(field: OrderByField) -> Self
Converts to this type from the input type.
Source§impl PartialEq for OrderByField
impl PartialEq for OrderByField
impl Eq for OrderByField
impl StructuralPartialEq for OrderByField
Auto Trait Implementations§
impl Freeze for OrderByField
impl RefUnwindSafe for OrderByField
impl Send for OrderByField
impl Sync for OrderByField
impl Unpin for OrderByField
impl UnwindSafe for OrderByField
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
Mutably borrows from an owned value. Read more