Struct takoyaki::PrintableGrid

source ·
pub struct PrintableGrid {
    pub grid: Vec<Vec<Printable>>,
}
Expand description

Handles printing the data to the terminal

Fields§

§grid: Vec<Vec<Printable>>

The raw grid

Implementations§

source§

impl PrintableGrid

source

pub fn new() -> Self

Creates a new instance of the printable

Example:
use takoyaki::PrintableGrid;

let printable = Printable::new()
source

pub fn pluck(data: &Value, dest: &str) -> Value

Iterates over the raw data and find the data at the specific destionation

Arguments
  • data - The raw data that needs to be looped through
  • dest - A string that includes all the key path to the destination separated by dots.
Example:
use takoyaki::PrintableGrid;
use serde_json::json;

let data = json!({
    "children": {
        "are_human_dumb": true
    }
});

assert_eq!(PrintableGrid::pluck(&data, "children.are_human_dumb"), json!(true))
source

pub fn insert_at(&mut self, x: usize, y: usize, item: Printable)

Inserts a item at x and y positions in a 2d grid

Arguments
  • x: The position on the x asis
  • y: The position on the y asis
  • item: The item that needs to be inserted
Example
use takoyaki::{PrintableGrid,Printable};

let mut grid = PrintableGrid::new();

let printable = Printable { color: "".to_string(), count: 0 };
grid.insert_at(2, 2, printable.clone());

assert_eq!(grid.grid[2][2], printable);
source

pub fn generate_grid(&mut self, opts: PrintOptions<'_>, data: Value)

Generates the grid according the the print option

source

pub fn pretty_print(&self) -> Result<()>

Pretty prints the grid

Trait Implementations§

source§

impl Default for PrintableGrid

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more