pub struct QueryResultTable { /* private fields */ }Expand description
A table for displaying query results.
Provides rich formatting for query result sets including type-based coloring, auto-sized columns, and multiple output formats.
Implementations§
Source§impl QueryResultTable
impl QueryResultTable
Sourcepub fn from_data(columns: Vec<String>, rows: Vec<Vec<String>>) -> Self
pub fn from_data(columns: Vec<String>, rows: Vec<Vec<String>>) -> Self
Create a query result table from column names and row data.
This is a convenience constructor that directly sets columns and rows.
§Example
use sqlmodel_console::renderables::QueryResultTable;
let columns = vec!["id".to_string(), "name".to_string()];
let rows = vec![
vec!["1".to_string(), "Alice".to_string()],
vec!["2".to_string(), "Bob".to_string()],
];
let table = QueryResultTable::from_data(columns, rows);Sourcepub fn columns(
self,
columns: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn columns( self, columns: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Set the column names.
Sourcepub fn row(self, values: impl IntoIterator<Item = impl Into<String>>) -> Self
pub fn row(self, values: impl IntoIterator<Item = impl Into<String>>) -> Self
Add a row of string values (types inferred).
Sourcepub fn rows(
self,
rows: impl IntoIterator<Item = impl IntoIterator<Item = impl Into<String>>>,
) -> Self
pub fn rows( self, rows: impl IntoIterator<Item = impl IntoIterator<Item = impl Into<String>>>, ) -> Self
Add multiple rows at once.
Sourcepub fn with_row_numbers(self) -> Self
pub fn with_row_numbers(self) -> Self
Enable row numbers.
Sourcepub fn plain_format(self, format: PlainFormat) -> Self
pub fn plain_format(self, format: PlainFormat) -> Self
Set the plain format for non-styled output.
Sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Get the number of columns.
Sourcepub fn render_plain(&self) -> String
pub fn render_plain(&self) -> String
Render as plain text using the configured format.
Sourcepub fn render_plain_format(&self, format: PlainFormat) -> String
pub fn render_plain_format(&self, format: PlainFormat) -> String
Render as plain text using a specific format.
Sourcepub fn render_styled(&self) -> String
pub fn render_styled(&self) -> String
Render as styled text with ANSI colors and box drawing.
Trait Implementations§
Source§impl Clone for QueryResultTable
impl Clone for QueryResultTable
Source§fn clone(&self) -> QueryResultTable
fn clone(&self) -> QueryResultTable
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 QueryResultTable
impl Debug for QueryResultTable
Auto Trait Implementations§
impl Freeze for QueryResultTable
impl RefUnwindSafe for QueryResultTable
impl Send for QueryResultTable
impl Sync for QueryResultTable
impl Unpin for QueryResultTable
impl UnsafeUnpin for QueryResultTable
impl UnwindSafe for QueryResultTable
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