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");

Create an empty grid.

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 Maps 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.

Return the number of rows in the grid.

Return true if the grid has no rows.

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.

Returns true if the grid appears to be an error grid.

Return the error trace if present.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.