Struct raystack::Grid [−][src]
pub struct Grid { /* fields omitted */ }
Expand description
A wrapper around a serde_json::Value
which represents a Haystack Grid.
Columns will always be sorted in alphabetical order.
Implementations
Create a new Grid
from rows. Each row must be a JSON Object.
Example
use raystack::Grid; use serde_json::json; let row = json!({"firstName": "Otis", "lastName": "Jackson Jr."}); let rows = vec![row]; let grid = Grid::new(rows).unwrap(); assert_eq!(grid.rows()[0]["firstName"], "Otis");
Return a map which represents the metadata for the grid.
Return an owned map, which represents the metadata for the grid.
Return a vector of JSON values which represent the columns of the grid.
Add a new column, or overwrite an existing column by mapping each row to a new cell value.
Return a vector of owned JSON values which represent the columns of the grid.
Return a vector containing the column names in this grid.
Return a vector containing the column names in this grid, as strings.
Return a vector containing the values in the given column.
Returns true if the grid contains the given column name.
Remove the column name from the grid if it is present, and return true if the column was removed.
Remove the column names from the grid and return the number of columns that were removed. If a column name is not in the grid, nothing happens for that column name, and it does not increase the count of removed columns.
Keep the given column names and remove all other columns. If the column name is not present, nothing happens for that column name.
Rename a column in the grid. If the original column was contained in the grid, return true. If the original column did not exist in the grid, this function does not modify the grid, and returns false.
Modify the grid by applying the mapping function to each value in the specified column.
Return a vector of JSON values which represent the rows of the grid.
Return a vector of Map
s which represent the rows of the grid.
Return a vector of owned JSON values which represent the rows of the grid.
Return a vector of owned JSON values which represent the rows of the grid.
Sort the rows with a comparator function. This sort is stable.
Add a row to the grid. The row must be a JSON object.
Add rows to the grid. The rows to add must be a Vec
containing
only JSON objects.
Concatenate the rows in the given grid to the current grid.
For each given grid, concatenate its rows to the current grid.
Return a new grid which is formed by concatenating all the given grids together.
Return the string representation of the underlying JSON value.
Return a pretty formatted string representing the underlying JSON value.
Return the error trace if present.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Grid
impl UnwindSafe for Grid
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more