Writing php extensions in rust made easy
  • Rust 99.5%
  • C 0.5%
Find a file
2019-04-06 15:57:07 +02:00
examples/helloworld more literal type casting 2019-04-05 20:03:49 +02:00
ivory return type casting for arrays 2019-04-06 15:57:07 +02:00
tests return type casting for arrays 2019-04-06 15:57:07 +02:00
.gitignore Implemented to build empty php extension in Rust 2017-08-12 15:16:07 +08:00
LICENSE Initial commit 2017-08-11 23:38:22 -05:00
README.md extend readme a bit 2019-04-05 21:36:36 +02:00

Ivory

Writing php extensions in rust made easy

Usage

use ivory::{ivory_export, ivory_module};
use ivory::externs::printf;

/// Basic methods
#[ivory_export]
fn hello_world() {
    printf("Hello world, Rust!");
}

/// Automatically casts function arguments for php
#[ivory_export]
fn hello_other(other: String) {
    printf(format!("Hello {}", other));
}

/// And casts return types back to php
#[ivory_export]
fn add_one(input: i64) -> i64 {
    input + 1
}

/// Optional arguments
#[ivory_export]
fn hello(input: Option<String>) {
    printf(format!("Hello {}", other.unwrap_or("Rust".to_string())));
}

ivory_module!({
    name: "demo",
    version: "0.0.1",
    info: &[("demo extension", "enabled")]
});