Initial commit and progress blocking out
This commit is contained in:
commit
cef39ef57a
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
1511
Cargo.lock
generated
Normal file
1511
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
Normal file
12
Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "spatial-db"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
axum = "0.6.20"
|
||||
clap = { version = "4.4.5", features = ["derive"] }
|
||||
parquet = "47.0.0"
|
||||
tokio = { version = "1.32.0", features = ["macros", "rt-multi-thread"] }
|
22
src/main.rs
Normal file
22
src/main.rs
Normal file
@ -0,0 +1,22 @@
|
||||
mod storage;
|
||||
mod storage_server;
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Args {
|
||||
/// `http` starts a build-in http server that listens for reads and writes
|
||||
/// to the database
|
||||
#[arg(long)]
|
||||
http: bool,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
if args.http {
|
||||
println!("Proxy was enabled");
|
||||
storage_server::main();
|
||||
}
|
||||
println!("Hello, world!");
|
||||
}
|
11
src/storage/interface.rs
Normal file
11
src/storage/interface.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use crate::storage::world::{BlockID, BlockPos};
|
||||
|
||||
enum StorageInterface {
|
||||
/// `ChangeBlock` changes the block at the world position given by `world_position` to the
|
||||
/// target block id `BlockID`
|
||||
ChangeBlock {
|
||||
target_state: BlockID,
|
||||
world_position: BlockPos,
|
||||
},
|
||||
ChangeBlockRange(BlockID, BlockPos, BlockPos),
|
||||
}
|
2
src/storage/mod.rs
Normal file
2
src/storage/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
mod interface;
|
||||
mod world;
|
32
src/storage/world.rs
Normal file
32
src/storage/world.rs
Normal file
@ -0,0 +1,32 @@
|
||||
type ChunkCoordinate = isize;
|
||||
|
||||
const SECTIONS_PER_CHUNK: usize = 16;
|
||||
|
||||
struct ChunkData {
|
||||
x: ChunkCoordinate,
|
||||
y: ChunkCoordinate,
|
||||
sections: [ChunkSection; SECTIONS_PER_CHUNK],
|
||||
}
|
||||
|
||||
// https://wiki.vg/Chunk_Format
|
||||
struct ChunkSection {
|
||||
/// The number of non-empty blocks in the section. If completely full, the
|
||||
/// section contains a 16 x 16 x 16 cube of blocks = 4096 blocks
|
||||
/// If the section is empty, this is skipped
|
||||
block_count: u16,
|
||||
block_states: [BlockID; 4096],
|
||||
}
|
||||
|
||||
/// `BlockPos` represents the location of a block in world space
|
||||
pub struct BlockPos {
|
||||
x: isize,
|
||||
y: isize,
|
||||
z: isize,
|
||||
}
|
||||
|
||||
/// BlockID represents the type of block stored
|
||||
#[repr(u8)]
|
||||
pub enum BlockID {
|
||||
Empty,
|
||||
Generic,
|
||||
}
|
11
src/storage_server.rs
Normal file
11
src/storage_server.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use axum::{routing::get, Router};
|
||||
|
||||
#[tokio::main]
|
||||
pub async fn main() {
|
||||
let app = Router::new().route("/", get(|| async { "Hello World" }));
|
||||
|
||||
axum::Server::bind(&"0.0.0.0:5000".parse().unwrap())
|
||||
.serve(app.into_make_service())
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
Loading…
Reference in New Issue
Block a user