Skip to main content

Crate ikigai_fn

Crate ikigai_fn 

Source
Expand description

ikigai-fn — a library of reusable function endpoints.

This is the first ikigai module crate: a standalone library of resolvable function endpoints that a host links in and mounts, rather than the engine shipping behaviour itself. It depends only on the published ikigai-core kernel, uses no OS or platform APIs, and compiles to wasm32-unknown-unknown — so the same module links into a native CLI and into the in-browser WebAssembly host alike (no WASI required yet).

Each snake_case constructor builds an endpoint whose lowerCamelCase identifier matches its name — to_upper builds the toUpper endpoint, conventionally resolved at urn:iki:fn:toUpper. A host either pulls the constructors and binds them at IRIs of its choosing, or mounts the whole library at its conventional IRIs with space.

Re-exports§

pub use prefix::prefix_check;
pub use prefix::prefix_expand;
pub use prefix::prefix_space;
pub use prefix::RESERVED_SCHEMES;

Modules§

aggregate
Reporting types for aggregate counts about people.
html
Escaping and URL rules for HTML built from data: ONE implementation for every door.
markdown
Markdown from people the host does not trust, rendered as an XHTML fragment: ONE walker for every door. render_untrusted serves a host that renders without a kernel round trip; crate::markdown() serves the same walker at urn:iki:fn:markdown.
prefix
Prefixes as scoped names: json:query for urn:json:query, inside a dynamic space that wraps a composition, and nowhere else.

Structs§

Compose
compose: a request-template language — NetKernel’s TRL, resolved through the kernel.
ComposeOver
composeOver: a template bound at a NAME — Compose with its src fixed.
Conditional
conditional: the lazy sibling of Compose. Sources the if resource, reads it as a boolean, and sources — and returns — only then (true) or the optional else (false). The untaken branch is never invoked, so neither its work nor its golden threads enter the result. if is always evaluated; a false condition with no else yields an empty representation. Because each branch is taken via inv.source, dependencies propagate: if if’s value later flips (its thread is cut), the conditional recomputes and can take the other branch.
Each
each: render a collection — fill the template template once per element of the JSON array src answers, and concatenate the fills in order.

Constants§

COMPOSE_MAX_NODES
Maximum literal and marker nodes produced by one template fill, including every recursive $a expansion. Repeated uses count again even when their resource is cached. Each element of each is a separate fill.
COMPOSE_OVER
The name every ComposeOver answers until it is named: the KIND of endpoint it is.
EACH_MAX_ELEMENTS
The most elements each fills a template for: 10,000. More is refused, naming the bound, before any template is filled.
EACH_MAX_FIELDS
The most fields one object element may carry: 256.
EACH_MAX_OUTPUT
The most bytes each answers: 8 MiB. A longer answer is refused, naming the bound.
JQ_QUERY
The resource a $j{<src> <program>} marker names: ikigai-json’s jq selection. The marker is sugar for $h{urn:json:query?src=<src>&q=<program>&as=text/plain}, always this full name, so it works with or without a prefix table.
MARKER_LETTERS
The letters that open a compose marker — $a{…}, $r{…}, $h{…}, $j{…} — in the order compose learned them (a in 0.2, r and h in 0.3, j in 0.6).
SPACE_ID
The name space claims: urn:iki:space:fn.

Functions§

compose
compose: fill the template named by src. See Compose.
compose_over
composeOver: the template src, filled — bind it at the name of a view. See ComposeOver.
conditional
conditional: branch on a boolean resource, invoking only the taken side. See Conditional.
digest
digest: the BLAKE3 content id of the exact UTF-8 bytes in in.
each
each: one template fill per element of a JSON array. See Each.
echo
echo: returns the message variable captured by the resolving grammar — demonstrates grammar bindings (e.g. urn:demo:echo/{message}) flowing to an endpoint.
escape_markers
text written so that compose renders it exactly as it is: no marker in it resolves, and every $ survives.
greet
greet: combines greeting and name into "{greeting}, {name}" — the multi-argument function (source urn:demo:greet greeting=Hello name=World).
html_to_text
html-to-text: the words the HTML in in shows a reader, as one line of plain text (html::to_text) — the text face a lift stores beside an RSS description, so a search runs over words and not over strong, img or href.
markdown
markdown: the untrusted Markdown in content as a well-formed XHTML fragment (markdown::try_render_untrusted). Input past the module’s size or nesting bound is refused as Error::OverBudget.
reverse_list
reverseList: reverses the order of newline-separated items in in.
space
The reusable function library as a mountable EndpointSpace, binding every function at its conventional IRI. A host mounts this and chains its own host-specific bindings on top — EndpointSpace::bind is a builder, so:
split
split: splits the in argument on commas (trimming each) into a newline-separated list — a list producer for the .. map operator (source urn:demo:split "a, b, c" .. urn:iki:fn:toUpper). The newline list is the same convention reverse_list reads.
to_upper
toUpper: upper-cases the UTF-8 string in the in argument.
wrap
wrap: surrounds the text argument with square brackets. Its argument is deliberately named text, not in, so contract-driven routing is visible — source urn:demo:wrap hi works only because the contract says the input goes to text (and pipelines show their work: … | urn:demo:wrap → [HI]).