1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
//! The simple tables crate allows you to easily create table structures.
//!
//! # Getting started
//! You can use the macros [`table_row`](crate::macros::table_row) and [`table`](crate::macros::table)
//! to make a new table with the row structure defined by your table rows.
//!
//! **Example**
//! ```rust
//! # use simple_tables::macros::{table_row, table};
//!
//! #[table_row]
//! struct MyTableRow {
//! id: u32,
//! name: String,
//! email: String,
//! address: String
//! }
//!
//! #[table(rows = MyTableRow)]
//! struct MyTable {}
//! ```
//!
//! # Examples
//! ## Printing out a table
//!
//! You can use the `to_string()` method to convert a table to a formatted text table
//! and then print it out.
//!
//! ```rust
//! # use simple_tables::Table;
//! # use simple_tables::macros::{table_row, table};
//! #
//! # #[table_row]
//! # struct MyTableRow {
//! # id: u32,
//! # name: String,
//! # email: String,
//! # address: String
//! # }
//! #
//! # #[table(rows = MyTableRow)]
//! # struct MyTable {}
//!
//! let rows: Vec<MyTableRow> = vec![
//! MyTableRow{ id: 0, name: "David Bowie".to_string(), email: "david@bowie.com".to_string(), address: "England".to_string()},
//! MyTableRow{ id: 1, name: "David Gilmour".to_string(), email: "david@gilmour.com".to_string(), address: "England".to_string()},
//! MyTableRow{ id: 2, name: "Opeth".to_string(), email: "info@opeth.com".to_string(), address: "Sweden".to_string()},
//! MyTableRow{ id: 3, name: "The Beatles".to_string(), email: "info@beatles.com".to_string(), address: "England".to_string()}
//! ];
//!
//! let table = MyTable::from_vec(&rows);
//! let s = table.to_string();
//! println!("{}", s);
//! ```
//!
//! The output will be:
//! ```bash
//! +----+---------------+-------------------+---------+
//! | id | name | email | address |
//! +====+===============+===================+=========+
//! | 0 | David Bowie | david@bowie.com | England |
//! +----+---------------+-------------------+---------+
//! | 1 | David Gilmour | david@gilmour.com | England |
//! +----+---------------+-------------------+---------+
//! | 2 | Opeth | info@opeth.com | Sweden |
//! +----+---------------+-------------------+---------+
//! | 3 | The Beatles | info@beatles.com | England |
//! +----+---------------+-------------------+---------+
//! ```
//!
//! More examples can be found on [GitHub](https://github.com/jomy10/simple_tables).
//!
//! # Traits
//! - [Table](crate::Table)
//! - [TableRow](crate::TableRow)
//! - [IdTable](crate::IdTable)
//!
//! # Macros
//! - [table_row](crate::macros::table_row)
//! - [table](crate::macros::table)
// Core libraries
pub extern crate simple_tables_core as core;
pub extern crate simple_tables_derive as derive;
// Library structure
pub mod macros {
pub use derive::table_row as table_row;
pub use derive::table as table;
}
pub use core::Table;
pub use core::TableRow;
pub use core::IdTable;
pub use core::error;