Skip to content

Commit 52fc61e

Browse files
committed
v0.3.0-alpha
- project structure improvements - documentation improvements
1 parent 0ed81bd commit 52fc61e

File tree

15 files changed

+183
-159
lines changed

15 files changed

+183
-159
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
[package]
22
name = "rapid_naive_sql"
3-
version = "0.2.1-alpha"
3+
version = "0.3.0-alpha"
4+
authors = ["Andrew Kushyk <akushyk799 at proton.me>"]
45
edition = "2021"
6+
description = "Rapid Naive SQL is a database API designed for high-performance data management"
7+
license = "GPL-3.0-or-later"
8+
repository = "https://gitlab.com/git-user-cpp/rapid_naive_sql"
59

610
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
711

src/data/databases/tables/mod.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/data/databases/tables/rows/mod.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/data/mod.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,58 @@
11
/*
22
* NaiveSQL implemented in Rust.
33
* Copyright (C) 2024 Andrew Kushyk
4-
*
4+
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
77
* the Free Software Foundation, either version 3 of the License, or
88
* (at your option) any later version.
9-
*
9+
*
1010
* This program is distributed in the hope that it will be useful,
1111
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1212
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313
* GNU General Public License for more details.
14-
*
14+
*
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19+
use super::table::Table;
1920
use std::collections::HashMap;
2021

21-
use super::tables::table::Table;
22-
22+
/// Creates database
23+
///
24+
/// # Examples
25+
///
26+
/// ```
27+
/// use rapid_naive_sql::RNSQL;
28+
/// use rapid_naive_sql::database::table::Table;
29+
///
30+
/// let mut project: RNSQL<String> = RNSQL::new();
31+
/// if let Some(database) = project.databases.get_mut("database name") {
32+
/// let tb1 = Table::create_table();
33+
/// database.add_table("table name", tb1);
34+
/// }
35+
/// ```
2336
#[derive(Debug)]
2437
pub struct Database<Value> {
2538
pub tables: HashMap<String, Table<Value>>,
2639
}
2740

2841
impl<Value> Database<Value> {
42+
/// Creates a database that holds tables
2943
pub fn create_database() -> Self {
3044
Self {
3145
tables: HashMap::new(),
3246
}
3347
}
3448

49+
/// Adds a table to the existing database
3550
pub fn add_table(&mut self, name: &str, table: Table<Value>) {
3651
self.tables.insert(name.to_string(), table);
3752
}
3853

54+
/// Removes a table from the existing database
3955
pub fn delete_table(&mut self, name: &str) {
4056
self.tables.remove(name);
4157
}
42-
}
58+
}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
/*
22
* NaiveSQL implemented in Rust.
33
* Copyright (C) 2024 Andrew Kushyk
4-
*
4+
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
77
* the Free Software Foundation, either version 3 of the License, or
88
* (at your option) any later version.
9-
*
9+
*
1010
* This program is distributed in the hope that it will be useful,
1111
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1212
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313
* GNU General Public License for more details.
14-
*
14+
*
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

1919
pub mod database;
20-
pub mod tables;
20+
pub mod row;
21+
pub mod table;
Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,60 @@
11
/*
22
* NaiveSQL implemented in Rust.
33
* Copyright (C) 2024 Andrew Kushyk
4-
*
4+
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
77
* the Free Software Foundation, either version 3 of the License, or
88
* (at your option) any later version.
9-
*
9+
*
1010
* This program is distributed in the hope that it will be useful,
1111
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1212
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313
* GNU General Public License for more details.
14-
*
14+
*
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

1919
use std::collections::HashMap;
2020

21+
/// Creates row
22+
///
23+
/// # Examples
24+
///
25+
/// ```
26+
/// use rapid_naive_sql::RNSQL;
27+
///
28+
/// let mut project = RNSQL::new();
29+
///
30+
/// if let Some(database) = project.databases.get_mut("database name") {
31+
/// if let Some(table) = database.tables.get_mut("table name") {
32+
/// if let Some(row) = table.rows.get_mut(&1) {
33+
/// row.create_column("column name", String::from("hello"));
34+
/// }
35+
/// }
36+
/// }
37+
/// ```
2138
#[derive(Debug)]
2239
pub struct Row<Value> {
2340
pub columns: HashMap<String, Value>,
2441
}
2542

2643
impl<Value> Row<Value> {
44+
/// Creates a row that holds columns
2745
pub fn create_row() -> Self {
2846
Self {
2947
columns: HashMap::new(),
3048
}
3149
}
3250

51+
/// Adds a column to the existing row
3352
pub fn create_column(&mut self, name: &str, value: Value) {
3453
self.columns.insert(name.to_string(), value);
3554
}
3655

56+
/// Removes a column from the existing row
3757
pub fn delete_column(&mut self, name: &str) {
3858
self.columns.remove(name);
3959
}
40-
}
60+
}
Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,61 @@
11
/*
22
* NaiveSQL implemented in Rust.
33
* Copyright (C) 2024 Andrew Kushyk
4-
*
4+
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
77
* the Free Software Foundation, either version 3 of the License, or
88
* (at your option) any later version.
9-
*
9+
*
1010
* This program is distributed in the hope that it will be useful,
1111
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1212
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313
* GNU General Public License for more details.
14-
*
14+
*
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19+
use super::row::Row;
1920
use std::collections::HashMap;
20-
use crate::data::databases::tables::rows::row::Row;
2121

22+
/// Creates table
23+
///
24+
/// # Examples
25+
///
26+
/// ```
27+
/// use rapid_naive_sql::RNSQL;
28+
/// use rapid_naive_sql::database::row::Row;
29+
///
30+
/// let mut project: RNSQL<String> = RNSQL::new();
31+
///
32+
/// if let Some(database) = project.databases.get_mut("database name") {
33+
/// if let Some(table) = database.tables.get_mut("table name") {
34+
/// let rw1 = Row::create_row();
35+
/// table.add_row(1, rw1);
36+
/// }
37+
/// }
38+
/// ```
2239
#[derive(Debug)]
2340
pub struct Table<Value> {
2441
pub rows: HashMap<u32, Row<Value>>,
2542
}
2643

2744
impl<Value> Table<Value> {
45+
/// Creates a table that holds rows
2846
pub fn create_table() -> Self {
2947
Self {
3048
rows: HashMap::new(),
3149
}
3250
}
3351

52+
/// Adds a row to the existing table
3453
pub fn add_row(&mut self, primary_key: u32, row: Row<Value>) {
3554
self.rows.insert(primary_key, row);
3655
}
3756

57+
/// Removes a row from the existing table
3858
pub fn delete_row(&mut self, primary_key: u32) {
3959
self.rows.remove(&primary_key);
4060
}
41-
}
61+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/*
22
* NaiveSQL implemented in Rust.
33
* Copyright (C) 2024 Andrew Kushyk
4-
*
4+
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
77
* the Free Software Foundation, either version 3 of the License, or
88
* (at your option) any later version.
9-
*
9+
*
1010
* This program is distributed in the hope that it will be useful,
1111
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1212
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313
* GNU General Public License for more details.
14-
*
14+
*
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17-
*/
17+
*/

0 commit comments

Comments
 (0)