| Crates.io | apexforge_afe |
| lib.rs | apexforge_afe |
| version | 0.1.1 |
| created_at | 2025-06-20 08:40:30.027549+00 |
| updated_at | 2025-07-08 02:00:53.806625+00 |
| description | A Rust library for creating ApexForge .afe files with embedded Lua scripts |
| homepage | |
| repository | https://github.com/Natiqmammad/ApexForge_Afe |
| max_upload_size | |
| id | 1719293 |
| size | 23,605 |
A Rust library for generating .afe (ApexForge Executable) files, embedding Lua scripts with minimal metadata. Designed for simplicity and portability, it uses bincode and serde for efficient serialization and mlua for Lua 5.4 script validation.
.afe packages easily.mlua with standard libraries..afe files via bincode.Add to your Cargo.toml:
[dependencies]
apexforge_afe = "0.1.1"
Then build your project:
cargo build
Create and save a simple .afe file:
use apexforge_afe::AfeBuilder;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let mut builder = AfeBuilder::new("HelloWorld", "1.0");
builder
.add_lua_function("greet", vec!["name"], r#"print("Hello, "..name)"#)
.add_lua_code("greet('ApexForge')")
.set_permissions("rwxr-xr-x");
builder.save("hello.afe", "Printing 'Hello World!' Keyword".to_string())?;
println!("Created hello.afe");
Ok(())
}
AfeFile#[derive(Encode, Decode, Serialize, Deserialize, Debug, Clone)]
pub struct AfeFile {
pub version: u32,
pub app_name: String,
pub app_version: String,
pub lua_script: String,
pub permissions: String, // e.g., rwxr-xr-x
pub using: String, // e.g., lua54
}
AfeBuilderpub struct AfeBuilder {
app_name: String,
app_version: String,
lua_script: String,
permissions: String,
}
impl AfeBuilder {
pub fn new(app_name: &str, app_version: &str) -> Self;
pub fn set_permissions(&mut self, permissions: &str) -> &mut Self;
pub fn add_lua_function(&mut self, name: &str, args: Vec<&str>, body: &str) -> &mut Self;
pub fn add_lua_code(&mut self, code: &str) -> &mut Self;
pub fn build(&self, using: String) -> AfeFile;
pub fn save(&self, path: &str, using: String) -> Result<(), std::io::Error>;
}
.afe file.using field.save() method validates Lua code by loading it with mlua.using is a free-form string (e.g., "Printing Hello World" or "write hello world").rwxr-xr-x), not enforced automatically.Dual-licensed under MIT or Apache-2.0.
Made with ๐ฆ & โค๏ธ by the ApexForge community.