pub struct DdlDisplay { /* private fields */ }Expand description
DDL display for schema output with syntax highlighting.
Displays DDL statements with optional line numbers, dialect-specific highlighting, and change region highlighting for migration diffs.
Implementations§
Source§impl DdlDisplay
impl DdlDisplay
Sourcepub fn new(sql: impl Into<String>) -> Self
pub fn new(sql: impl Into<String>) -> Self
Create a new DDL display from SQL.
§Example
use sqlmodel_console::renderables::DdlDisplay;
let display = DdlDisplay::new("CREATE TABLE users (id INT);");Sourcepub fn dialect(self, dialect: SqlDialect) -> Self
pub fn dialect(self, dialect: SqlDialect) -> Self
Set the SQL dialect for highlighting.
Sourcepub fn line_numbers(self, show: bool) -> Self
pub fn line_numbers(self, show: bool) -> Self
Set whether to show line numbers.
Sourcepub fn highlight_changes(self, regions: Vec<ChangeRegion>) -> Self
pub fn highlight_changes(self, regions: Vec<ChangeRegion>) -> Self
Add change regions for diff highlighting.
Sourcepub fn add_change(self, region: ChangeRegion) -> Self
pub fn add_change(self, region: ChangeRegion) -> Self
Add a single change region.
Sourcepub fn get_dialect(&self) -> SqlDialect
pub fn get_dialect(&self) -> SqlDialect
Get the dialect.
Sourcepub fn shows_line_numbers(&self) -> bool
pub fn shows_line_numbers(&self) -> bool
Get whether line numbers are shown.
Sourcepub fn change_regions(&self) -> &[ChangeRegion]
pub fn change_regions(&self) -> &[ChangeRegion]
Get the change regions.
Sourcepub fn render_plain(&self) -> String
pub fn render_plain(&self) -> String
Render as plain text (no ANSI codes).
Returns the SQL with optional line numbers, suitable for agent consumption or non-TTY output.
§Example
use sqlmodel_console::renderables::DdlDisplay;
let display = DdlDisplay::new("SELECT 1;").line_numbers(true);
let plain = display.render_plain();
assert!(plain.contains("1 |"));Trait Implementations§
Source§impl Clone for DdlDisplay
impl Clone for DdlDisplay
Source§fn clone(&self) -> DdlDisplay
fn clone(&self) -> DdlDisplay
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 DdlDisplay
impl Debug for DdlDisplay
Auto Trait Implementations§
impl Freeze for DdlDisplay
impl RefUnwindSafe for DdlDisplay
impl Send for DdlDisplay
impl Sync for DdlDisplay
impl Unpin for DdlDisplay
impl UnwindSafe for DdlDisplay
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