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_untrustedserves a host that renders without a kernel round trip;crate::markdown()serves the same walker aturn:iki:fn:markdown. - prefix
- Prefixes as scoped names:
json:queryforurn: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.- Compose
Over composeOver: a template bound at a NAME —Composewith itssrcfixed.- Conditional
conditional: the lazy sibling ofCompose. Sources theifresource, reads it as a boolean, and sources — and returns — onlythen(true) or the optionalelse(false). The untaken branch is never invoked, so neither its work nor its golden threads enter the result.ifis always evaluated; a false condition with noelseyields an empty representation. Because each branch is taken viainv.source, dependencies propagate: ifif’s value later flips (its thread is cut), the conditional recomputes and can take the other branch.- Each
each: render a collection — fill the templatetemplateonce per element of the JSON arraysrcanswers, and concatenate the fills in order.
Constants§
- COMPOSE_
MAX_ NODES - Maximum literal and marker nodes produced by one template fill, including every
recursive
$aexpansion. Repeated uses count again even when their resource is cached. Each element ofeachis a separate fill. - COMPOSE_
OVER - The name every
ComposeOveranswers until it isnamed: the KIND of endpoint it is. - EACH_
MAX_ ELEMENTS - The most elements
eachfills 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
eachanswers: 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
composemarker —$a{…},$r{…},$h{…},$j{…}— in the order compose learned them (ain 0.2,randhin 0.3,jin 0.6). - SPACE_
ID - The name
spaceclaims:urn:iki:space:fn.
Functions§
- compose
compose: fill the template named bysrc. SeeCompose.- compose_
over composeOver: the templatesrc, filled — bind it at the name of a view. SeeComposeOver.- conditional
conditional: branch on a boolean resource, invoking only the taken side. SeeConditional.- digest
digest: the BLAKE3 content id of the exact UTF-8 bytes inin.- each
each: one template fill per element of a JSON array. SeeEach.- echo
echo: returns themessagevariable captured by the resolving grammar — demonstrates grammar bindings (e.g.urn:demo:echo/{message}) flowing to an endpoint.- escape_
markers textwritten so thatcomposerenders it exactly as it is: no marker in it resolves, and every$survives.- greet
greet: combinesgreetingandnameinto"{greeting}, {name}"— the multi-argument function (source urn:demo:greet greeting=Hello name=World).- html_
to_ text html-to-text: the words the HTML ininshows 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 overstrong,imgorhref.- markdown
markdown: the untrusted Markdown incontentas a well-formed XHTML fragment (markdown::try_render_untrusted). Input past the module’s size or nesting bound is refused asError::OverBudget.- reverse_
list reverseList: reverses the order of newline-separated items inin.- 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::bindis a builder, so: - split
split: splits theinargument 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 conventionreverse_listreads.- to_
upper toUpper: upper-cases the UTF-8 string in theinargument.- wrap
wrap: surrounds thetextargument with square brackets. Its argument is deliberately namedtext, notin, so contract-driven routing is visible —source urn:demo:wrap hiworks only because the contract says the input goes totext(and pipelines show their work:… | urn:demo:wrap→[HI]).