Expand description
§wow-sharedmedia
A Rust library for building World of Warcraft addons that register media assets — fonts, textures, sounds, borders, and statusbars — with LibSharedMedia-3.0.
§Overview
wow-sharedmedia provides stateless, one-shot operations for:
- Importing media files (PNG, TGA, WebP, JPEG, BLP, TTF, OTF, OGG, MP3, WAV) with automatic format conversion to WoW-compatible formats.
- Removing media entries and their associated files.
- Updating entry metadata (display key, tags, locale masks).
- Reading the addon’s
data.luafile into a typed Rust struct.
Each operation is atomic: read data.lua → modify → write data.lua.
No in-memory state, no dirty tracking, no separate save/generate/deploy steps.
§Installation
[dependencies]
wow-sharedmedia = "0.2"§Quick Start
use wow_sharedmedia::{ensure_addon_dir, import_media, read_data, ImportOptions, MediaType, DEFAULT_MAX_BACKUPS};
use std::path::Path;
fn main() -> Result<(), wow_sharedmedia::Error> {
// Initialize addon directory (creates data.lua, loader.lua, .toc, media/ subdirs)
let addon_dir = Path::new("AddOns/MyMedia");
ensure_addon_dir(addon_dir, DEFAULT_MAX_BACKUPS)?;
// Import a statusbar texture
let source = Path::new("assets/my-statusbar.png");
let opts = ImportOptions::new(MediaType::Statusbar, "My Bar", &source);
let result = import_media(addon_dir, opts, DEFAULT_MAX_BACKUPS)?;
println!("Imported: {} (ID: {})", result.entry.key, result.entry.id);
// Read all entries
let data = read_data(addon_dir)?;
for entry in &data.entries {
println!(" {} [{}] → {}", entry.key, entry.media_type, entry.file);
}
Ok(())
}§Addon Directory Structure
After ensure_addon_dir, the directory layout is driven by the folder
name. For a folder named MyMedia:
MyMedia/
├── MyMedia.toc # WoW addon manifest (auto-generated)
├── data.lua # Media registry (Lua table, single source of truth)
├── loader.lua # LSM registration script (auto-generated)
├── libraries/ # Vendored LibSharedMedia-3.0 dependencies
└── media/
├── statusbar/ # TGA texture files
├── background/ # TGA texture files
├── border/ # TGA texture files
├── font/ # TTF/OTF font files
└── sound/ # OGG audio filesIf the folder name starts with ! (e.g. !!!MyMedia), the .toc
file will be !!!MyMedia.toc but the in-addon title will strip the
leading ! characters (e.g. MyMedia).
Modules§
Structs§
- Addon
Data - Top-level data structure persisted in data.lua.
- Entry
Metadata - Type-specific metadata extracted at import time.
- Import
Options - Options for importing a media file.
- Import
Result - Result of an import operation.
- Import
Warning - Non-fatal warning from import.
- Media
Entry - A single media entry in the addon registry.
- Removed
Entry - Result of a remove operation.
- Update
Options - Options for updating an existing entry.
Enums§
- Error
- Core error type for the wow-sharedmedia library.
- Media
Type - Media type enumeration for LibSharedMedia categories.
Constants§
- DEFAULT_
MAX_ BACKUPS - Default maximum number of backup files retained per write.
- SCHEMA_
VERSION - Current data.lua schema version.
Functions§
- addon_
name - Extract the addon name from its directory path.
- addon_
title - Derive the human-readable addon title from the addon name.
- ensure_
addon_ dir - Initialize a LibSharedMedia-compatible addon directory.
- import_
media - Import a media file into the addon registry.
- read_
data - Read the current addon registry from
data.lua. - remove_
media - Remove a media entry: ensure addon exists → delete file → remove entry → write data.lua.
- update_
media - Update entry metadata: ensure addon exists → modify in memory → write data.lua.