MemTable - Inmemory tables for use in Rust

Build Status Crates.io Docs.rs

Overview

memtable provides a collection of table-oriented features for use inmemory.

This crate acts as the aggregator of all subcrates such as memtable-core and memtable-macros and should be the only crate imported when using features from either.

Installation

```toml [dependencies] memtable = "0.1"

Optionally, include features like macros

memtable = { version = "0.1", features = ["macros"] }

```

Usage

Most often, you will want to import the prelude to bring in relevant traits and structs:

```rust use memtable::prelude::*;

// Create a 2x3 (row x column) table of integers let mut table = FixedTable::from([ [1, 2, 3], [4, 5, 6], ]);

// Examine one of the values, replace it, and examine again asserteq!(table[(1, 2)], 6); table.insertcell(1, 2, 999); assert_eq!(table[(1, 2)], 999); ```

The Tables

In the core library, you will find four primary tables:

The Traits

The Extensions

Alongside the essentials, the library also provides several features that provide extensions to the table arsenal:

The Macros

Currently, there is a singular macro, Table, which is used to derive a table to contain zero or more of a specific struct.

```rust use memtable::Table;

[derive(Table)]

struct User { name: String, age: u8, }

// Derives a new struct, User{Table}, that can contain instances of User // that are broken up into their individual fields let mut table = UserTable::new();

// Inserting is straightforward as a User is considered a singular row table.pushrow(User { name: "Fred Flintstone".tostring(), age: 51, });

// You can also pass in a tuple of the fields in order of declaration table.pushrow(("Wilma Flintstone".tostring(), 47));

// Retrieval by row will provide the fields by ref as a tuple let (name, age) = table.row(0).unwrap(); asserteq!(name, "Fred Flintstone"); asserteq!(*age, 51);

// Tables of course provide a variety of other methods to inspect data asserteq!( table.namecolumn().collect::>(), vec!["Fred Flintstone", "Wilma Flintstone"], ); ```

The License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in vimvar by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.