aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index bf9e3c9..f9b1c8b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,3 +1,51 @@
+//! ModderBaas is a library that allows you to manage Minetest mods.
+//!
+//! The main point of the library is to be used by the `modderbaas` CLI application, however it can
+//! also be used in other Rust programs that want a (limited) API to interact with Minetest
+//! content.
+//!
+//! # Representation
+//!
+//! Most objects ([`Game`], [`World`], [`MineMod`], [`Modpack`]) are represented by the path to the
+//! on-disk directory that contains the corresponding game/world/mod/modpack. The initializers take
+//! care that the directory contains a valid object.
+//!
+//! Many of the query operations do not do any caching, so avoid calling them in tight loops. If
+//! you want to do a lot of name queries (e.g. to find installed mods), consider using a
+//! [`Snapshot`].
+//!
+//! # Racing
+//!
+//! ModderBaas expects that during the time of its access, no other application meddles with the
+//! directories. It will *not* lead to crashes, but you will get a lot more error return values.
+//!
+//! # Mutability
+//!
+//! Some objects support mutating their state. This is usually done by directly writing the data
+//! into the corresponding file. Therefore, those methods (even though they mutate state) only take
+//! a shared reference (`&self`) — keep that in mind!
+//!
+//! # Crate Structure
+//!
+//! Most game objects are implemented in their own module and re-exported at the crate root:
+//!
+//! * [`game`]
+//! * [`minemod`]
+//! * [`world`]
+//!
+//! Interacting with mods from the internet/ContentDB is done through two modules:
+//!
+//! * [`contentdb`]
+//! * [`download`]
+//!
+//! Some modules contain auxiliary functions:
+//!
+//! * [`kvstore`]
+//! * [`util`]
+//!
+//! Error definitions are in [`error`].
+//!
+//! [`baas`] contains functions and data to interact with the global Minetest installation.
use std::{fs, path::Path};
use log::debug;
@@ -22,6 +70,7 @@ pub mod world;
pub use baas::{Baas, Snapshot};
pub use contentdb::ContentDb;
pub use download::{Downloader, Source};
+pub use error::Error;
pub use game::Game;
pub use minemod::{MineMod, Modpack};
pub use world::World;
@@ -33,6 +82,8 @@ use error::Result;
/// Files for which `scanner` returns `Ok(..)` will be collected and returned. Files for which
/// `scanner` returns `Err(..)` will be silently discarded.
///
+/// This function is useful to iterate through the items in a directory and find fitting objects:
+///
/// ```rust
/// use modderbaas::minemod::MineMod;
/// let mods = scan("/tmp", |p| MineMod::open(p))?;