Crate janetrs[][src]

Expand description

Janetrs

A crate with high level bindings to Janet C API.

Goals

Provide a safe and ergonomic interface to the Janet C API to create Janet clients and Janet modules/libraries using Rust.

This project still are in it’s early stages, so breaking changes may happen, there is no minimal supported Rust version (MSRV) yet.

Notice that most doc tests will fail if the feature “almagation” or “link-system” aren’t set, because most of then need it for the Janet runtime to function properly.

Cargo Features

  • std: Enable some trait impl for types that only exist on the std and the Error trait
  • unicode: Enable more methods for JanetString and JanetBuffer
  • inline-more: More aggressive inlining
  • amalgation: Link the Janet runtime to the package, enabling to use the client module
  • unicode: Enable some unicode methods for JanetString and JanetBuffer
  • system: Use system header to get Janet functions
  • link-system: Link the Janet runtime to the package from the system, enabling to use the client module
  • nightly: Enable some parts of the crate that uses nightly features, to use this feature you must compile the crate using a nightly rust version

Environment variables

These variables are only used when the amalgation feature is enabled

It is possible to use environment variables to overwrite some Janet definitions.

  • JANET_RECURSION_GUARD=<integer>
  • JANET_MAX_PROTO_DEPTH=<integer>
  • JANET_MAX_MACRO_EXPAND=<integer>
  • JANET_STACK_MAX=<integer>

Licensing

This software is licensed under the terms of the MIT Public License.

TODO: Types/Traits: Lacking or Incomplete

  • Marshaling

[ ]: Lacking [I]: Incomplete [X]: Done

Probably there is much more missing, for that you can use the lowlevel module to access the raw C API of Janet if needed

TODO: Lib level

  • Better docs.
  • Marshalling mechanism

Re-exports

pub use evil_janet as lowlevel;

Modules

This module provides a allocator that uses the Janet scratch memory API to create objects tracked by the Janet Garbage Collector.

Janet array (vector) type.

Janet buffer (string) type.

This module implements anything required to run a Janet client.

Module for the Janet environment structure and methods.

Janet fibers (soft threads) type.

Janet function types.

Module for I/O related types and functions

Module of the JanetAbstract abstractions.

Module for the Janet Pointer type.

Janet String type.

Janet Struct (immutable HashMap) type.

Janet symbols and keywords types.

Janet table (mutable HashMap) type.

Janet tuple type.

Module for stuff that are not required either to use in a application or to write janet modules.

Macros

Creates a JanetArray containing the arguments.

A macro helper to use the default message when getting the wrong types in the function argument when the situations that are more complex than the ones handled in JanetArgs, like multiple accepted types.

Checks the specified version of Janet is equal of the used Janet. Emits a boolean.

Declare a Janet module.

janet_modDeprecated

A macro to make life easier creating modules for Janet from Rust.

Execute a function (JanetCFunction, Rust function or extern C function) and catch any janet panic that may happen as a Result.

Causes a panic in the Janet side (exception). Diferently of the Rust panic! macro, this macro does not terminate the current thread. Instead, it sends a error signal with the passed message where the Janet runtime takes care to properly exit.

jtrystd

Macro that tries to run a expression, and if it panics in the Rust side, it tries to recover from that and pass the Rust panic string to a Janet Panic.

Creates a JanetStruct containing the arguments key-value pairs.

Creates a JanetTable containing the arguments key-value pairs.

Creates a JanetTuple containing the arguments.

Structs

Janet is the central structure of the Janet Language.

Type that represents the Janet Abstract type.

Janet arrays are a fundamental datatype in Janet. Janet Arrays are values that contain a sequence of other values.

Janet buffers are the mutable version of JanetStrings. Since Janet strings can hold any sequence of bytes, including zeros, buffers share this same property and can be used to hold any arbitrary memory, which makes them very simple but versatile data structures. They can be used to accumulate small strings into a large string, to implement a bitset, or to represent sound or images in a program.

The error when converting Janets to C Janet types.

A lightweight green thread in Janet. It does not correspond to operating system threads.

A representation of a Janet function defined at the Janet side.

The Janet Garbage Collector type.

An RAII implementation of a “scoped lock” of the Janet GC. When this structure is dropped (falls out of scope), the lock will be unlocked.

An RAII implementation of a rooted Janet value. When this structure is dropped (falls out of scope), the rooting will be undone.

Janet keyword. Janet being a lisp-like language a keyword is not a especial word of the language, it is a normal string that can be defined by the user.

Janet pointer type.

Type representing the Janet pseudorandom number generator

Janet strings are a immutable type that are similar to Janet buffers.

JanetStructs are immutable data structures that map keys to values.

Janet symbol type. Usually used to name things in Janet.

Janet tables are mutable data structures that map keys to values. Values are put into a Janet table with a key, and can be looked up later with the same key. Tables are implemented with an underlying open hash table, so they are quite fast and cache friendly.

Janet tuples are immutable, sequential types that are similar to Janet arrays.

Enums

Signals that can be produced by a JanetFunction and JanetCFunction representing that those worked correctly or not.

Representation of all Janet types.

Janet type in the form of a Tagged Union.

Traits

A trait to express a deep equality.

The trait that encodes the information required to instatiate the implementer as JanetAbstract

Trait that only exist to extend methods over [Janet] so it’s easier to get #[janet_fn] args.

Trait that express the ability of a Janet collection to extend it with another collection.

Trait defining the name of the type known to Janet

Type Definitions

C function pointer that is accepted by Janet as a type.

Attribute Macros

Conditional Janet Version Gate

Macro that tranforms a high-level Janet function (fn(&mut [Janet]) -> Janet) to the thing the Janet C API is expecting (fn(i32, *mut janetrs::lowlevel::Janet) -> janetrs::lowlevel::Janet)

Conditional Janet Version Gate