Skip to content

Plugins

Further examples

More examples of Surrealism in practice can be seen inside the surrealism repo.

This demo contains examples of the #[surrealism] attribute in real code.

You can rename a function on the SurrealDB side:

#[surrealism(name = "other")]
fn can_drive_bla(age: i64) -> bool {
    age >= 18
}

You can make a function the default, allowing calls via the module path alone:

#[surrealism(default)]
fn def(age: i64) -> bool {
    age >= 18
}
#[surrealism(comment = "Parses a string into a number")]
fn parse_number(input: String) -> Result<i64, String> {
    input.parse::<i64>().map_err(|e| e.to_string())
}

This file shows ways to work with module archives directly from the CLI.

# Scaffold a new module project
surreal module init

# Build quickly while iterating
surreal module build --debug --out demo.surli .

# See function signature
surreal module sig --fnc can_drive demo.surli

# Run function with argument 
surreal module run --fnc can_drive --arg 17 demo.surli

Was this page helpful?