std.shared

Read-only strings shared across isolates.

Importuse std.shared

Functions

extern fn freeze(text: string) -> string#

Copies text into immutable shared storage.

  • text: Text to copy into shared storage.
let config = std.shared.freeze("{\"mode\":\"fast\"}")
println(std.shared.is_shared(config))
println(std.shared.entries())
println(std.shared.bytes_used())
extern fn is_shared(text: string) -> bool#

Reports whether text already resides in shared storage.

  • text: Text to test.
extern fn entries() -> int#

Returns the number of entries in shared storage.

extern fn bytes_used() -> int#

Returns the bytes retained in shared storage.

extern fn put(key: string, value: string) -> string#

Publishes a key/value pair and returns the retained shared value.

  • key: Name to publish under.
  • value: Text to retain in shared storage.
std.shared.put("mode", "fast")
if std.shared.has("mode") {
  println(std.shared.get("mode").unwrap())
}
println(std.shared.keys_published())
extern fn get(key: string) -> Optional<string>#

Returns a published value, or none when the key is absent.

  • key: Name to look up.
extern fn has(key: string) -> bool#

Reports whether the shared key has been published.

  • key: Name to look up.
extern fn keys_published() -> int#

Returns the number of keys published to shared storage.