Skip to content

Commit 3014b9c

Browse files
committed
Bold displaying of columns headers, docsting for WrapperDisplay
1 parent d91a069 commit 3014b9c

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

scylla/src/response/query_result.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ impl fmt::Display for RowsDisplayer<'_> {
770770
// ).collect();
771771

772772
table = table.with(Colorization::exact(
773-
[Color::FG_MAGENTA],
773+
[Color::FG_MAGENTA | Color::BOLD],
774774
tabled::settings::object::Rows::first(),
775775
));
776776
// .with(Colorization::columns(colum_colors))
@@ -796,6 +796,7 @@ struct RowsDisplayerSettings {
796796
colors: ValueColors,
797797
}
798798

799+
799800
impl RowsDisplayerSettings {
800801
fn new() -> Self {
801802
// TODO write Default trait
@@ -878,12 +879,43 @@ pub enum ByteDisplaying {
878879

879880
// wrappers for scylla datatypes implementing Display
880881

882+
883+
/// A wrapper struct for displaying various Scylla CQL value types with custom formatting settings.
884+
///
885+
/// This struct is used to format and display different CQL value types according to the provided
886+
/// display settings. It supports various formatting options such as color usage, byte display format,
887+
/// exponent display for floats and integers, and precision for doubles.
888+
///
889+
/// # Type Parameters
890+
///
891+
/// - `T`: The type of the value to be displayed.
892+
///
893+
/// # Fields
894+
///
895+
/// - `value`: A reference to the value to be displayed.
896+
/// - `settings`: A reference to the display settings to be used for formatting.
897+
///
898+
/// # Example
899+
///
900+
/// ```rust
901+
/// use scylla::transport::query_result::{WrapperDisplay, RowsDisplayerSettings};
902+
///
903+
/// let settings = RowsDisplayerSettings::new();
904+
/// let value = 42;
905+
/// let wrapper = WrapperDisplay { value: &value, settings: &settings };
906+
/// println!("{}", wrapper);
907+
/// ```
908+
///
909+
/// This will print the value `42` formatted according to the provided settings.
910+
881911
struct WrapperDisplay<'a, T: 'a> {
882912
value: &'a T,
883913
settings: &'a RowsDisplayerSettings,
884914
}
885915

886-
// Trait bound to ensure From<WrapperDisplay<T>> for String is implemented
916+
/// A trait for types that can be converted to a `String`.
917+
///
918+
/// Trait bound to ensure From<WrapperDisplay<T>> for String is implemented
887919
trait StringConvertible<'a>: 'a + fmt::Display {
888920
fn to_string(&self) -> String;
889921
}

0 commit comments

Comments
 (0)