GithubHelp home page GithubHelp logo

kawogi / rust-minetestworld Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ugniljoz/rust-minetestworld

0.0 0.0 0.0 2.45 MB

Read and write minetest world data in Rust

Home Page: https://docs.rs/crate/minetestworld/

License: GNU Affero General Public License v3.0

Rust 99.74% Mathematica 0.26%

rust-minetestworld's Introduction

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 backends

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.

See minetest-worldmapper for a real-world example.

rust-minetestworld's People

Contributors

ugniljoz avatar kawogi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.