Built-in Rust/Rustler type vocabulary for RustQ.Meta.defrust/2 specs.
Prefer ordinary Elixir types when they fit. RustQ.Meta maps built-ins such
as atom(), term(), boolean(), integer(), float(), and binary() to
Rust/Rustler types. Use ordinary remote types for external Rust paths where
possible: SkiaSafe.Canvas.t() renders as skia_safe::Canvas, and
GeneratedOpts.OvalOpts.t(R.lifetime(:a)) renders as
generated_opts::OvalOpts<'a>. Use this module where Rust needs extra
precision or syntax that Elixir types cannot express cleanly: fixed-width
numbers, enum intent markers, references, lifetimes, slices, NifResult,
Vec, and unit.
alias RustQ.Type, as: R
@spec draw(R.ref(SkiaSafe.Canvas.t()), R.f32(), R.f32()) :: R.nif_result(R.unit())
defrust draw(canvas, x, y) do
canvas.translate({x, y})
:ok
end
@spec decode_mode(atom()) :: R.nif_result(Mode.t())
defrust decode_mode(atom) do
# atom() maps to Rustler Atom
endThe functions with matching names are marker helpers for non-typespec macro
contexts and for the reserved built-in names (R.atom(), R.bool(),
R.term()). They are not runtime APIs.
Summary
Types
Enum intent marker for domain-specific descriptor resolution.
Rust f32.
Rust f64.
Rust i64.
Rust lifetime marker for external remote types and low-level R.path/2.
Rust mutable reference &mut T.
Rustler NIF error marker.
Rustler NifResult<T>.
Rust Option<T>.
Low-level explicit Rust path marker. Prefer ordinary remote types such as GeneratedOpts.OvalOpts.t(...) when possible.
Low-level explicit Rust path marker with options such as R.lifetime(:a). Prefer ordinary remote types when possible.
Raw Rust type fragment marker for syntax Elixir typespecs cannot model. Prefer structural markers such as R.slice/1 when possible.
Rust shared reference &T.
Rust Result<Ok, Error>.
Rust slice reference &[T].
Rust string slice &str.
Rust u8.
Rust u32.
Rust (); represented as :ok/unit-ish data in Elixir specs.
Rust Vec<T>.
Types
@type enum(name) :: atom() | {name}
Enum intent marker for domain-specific descriptor resolution.
@type f32() :: float()
Rust f32.
@type f64() :: float()
Rust f64.
@type i64() :: integer()
Rust i64.
@type lifetime(name) :: {name, term()}
Rust lifetime marker for external remote types and low-level R.path/2.
@type mut_ref(t) :: t
Rust mutable reference &mut T.
@type nif_error() :: atom()
Rustler NIF error marker.
@type nif_result(t) :: {:ok, t} | {:error, nif_error()}
Rustler NifResult<T>.
@type option(t) :: nil | t
Rust Option<T>.
@type path(parts) :: {parts, term()}
Low-level explicit Rust path marker. Prefer ordinary remote types such as GeneratedOpts.OvalOpts.t(...) when possible.
@type path(parts, opts) :: {parts, opts, term()}
Low-level explicit Rust path marker with options such as R.lifetime(:a). Prefer ordinary remote types when possible.
@type raw(name) :: {name, term()}
Raw Rust type fragment marker for syntax Elixir typespecs cannot model. Prefer structural markers such as R.slice/1 when possible.
@type ref(t) :: t
Rust shared reference &T.
@type result(ok, error) :: {:ok, ok} | {:error, error}
Rust Result<Ok, Error>.
@type slice(t) :: {t, term()}
Rust slice reference &[T].
@type str() :: binary()
Rust string slice &str.
@type u8() :: 0..255
Rust u8.
@type u32() :: non_neg_integer()
Rust u32.
@type unit() :: :ok
Rust (); represented as :ok/unit-ish data in Elixir specs.
@type vec(t) :: [t]
Rust Vec<T>.
Functions
@spec atom() :: no_return()
@spec bool() :: no_return()
@spec f32() :: no_return()
@spec f64() :: no_return()
@spec i8() :: no_return()
@spec i16() :: no_return()
@spec i32() :: no_return()
@spec i64() :: no_return()
@spec isize() :: no_return()
@spec str() :: no_return()
@spec term() :: no_return()
@spec u8() :: no_return()
@spec u16() :: no_return()
@spec u32() :: no_return()
@spec u64() :: no_return()
@spec unit() :: no_return()
@spec usize() :: no_return()