Skip to content

ETS

ETS is a stdlib, not a module role. gale_std.ets.new creates a named table whose type is Ets<Name, K, V>. Name is a phantom identity selected by the expected type, so separately annotated :users and :sessions handles cannot be mixed. The calling process owns the table. Put it behind a module implementing gale_std.gen_server.Server if you want a dedicated owner. insert, lookup, lookup_all, and delete return Result.

Those results come from declared ArgumentError boundaries on the native ETS functions. ETS does raise for invalid table identifiers, access violations, and invalid objects; Gale selectively rescues that documented exception without routing every operation through a runtime adapter.

The same pattern applies to the other BEAM tables and OTP supervisors in gale_std: gale_std.registry (Registry<N, K, V>), gale_std.persistent_term (global keys), gale_std.dynamic_supervisor (start_child takes ChildSpec<A>), and gale_std.task_supervisor (see Tasks).

pub fn round_trip() -> Result<Option<Binary>, gale_std.ets.EtsError> {
with {
table <- gale_std.ets.new(:example_ets, :set, :public)
_ <- gale_std.ets.insert(table, 1, "one")
found <- gale_std.ets.lookup(table, 1)
found
}
}

named rebinds an existing named table without creating it. Its expected phantom, key, and value types are an explicit foreign contract.

let users = gale_std.ets.named(:users)