13 releases

0.5.4 Dec 23, 2023
0.5.3 Jul 15, 2023
0.5.2 Jan 20, 2023
0.5.0 Dec 29, 2022
0.3.1 Mar 22, 2022

#299 in Database interfaces


Used in minetest-worldmapper

AGPL-3.0

1.5MB
1K SLoC

minetestworld

This crate lets you read minetest worlds in a low-level way.

Build Crates.io Documentation dependency status

Usage

As this crate returns async-std based futures, you have to specify that along the dependencies:

[dependencies]
minetestworld = "0.5.3"
async-std = "1"

An example

Here is an example that reads all nodes of a specific map block:

[dependencies]
async-std = { version = "1", features = [ "attributes" ] }
minetestworld = "0.5.3"
use std::error::Error;
use async_std::task;
use async_std::stream::StreamExt;
use minetestworld::{World, Position};

#[async_std::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let world = World::open("TestWorld");
    let mapdata = world.get_map_data().await?;

    // Take the first mapblock position we can grab
    let mut positions = mapdata.all_mapblock_positions().await;
    let blockpos = positions.next().await.unwrap()?;

    // Iterate all nodes in that mapblock
    for (pos, node) in mapdata.iter_mapblock_nodes(blockpos).await? {
        let param0 = String::from_utf8(node.param0)?;
        println!("{pos:?}, {param0:?}");
    }
    Ok(())
}

Selectable features

The Cargo features sqlite, redis, and postgres enable the respective map data backend. They are enabled by default and can be selected individually:

[dependencies]
minetestworld = { version = "0.5.3", default-features = false, features = [ "sqlite" ] }

This crate only compiles if at least one backend is enabled, because it becomes pointless without.

To gain TLS support for the postgres connection, add the tls-rustls or the tls-native-tls feature.

See minetest-worldmapper for a real-world example.

Dependencies

~10–27MB
~454K SLoC