componentized/directory

Synthetic sample. This package shows how the directory renders each WIT feature. It isn't published to any registry.

Futures, streams and error contexts, and async functions.

Types

use resource canvas

from kitchen-sink:types/resources@0.1.0

A resource with every kind of member.

  • constructor functionconstructor(width: u32, height: u32)

    Makes an empty canvas.

  • functionplot: func(at: point, color: list<u8, 4>)

    A method.

  • functioncopy-from: func(other: borrow<canvas>) -> result<_, string>

    A method that borrows another canvas.

  • functionsnapshot: func() -> canvas

    A method that hands back a resource it owns.

  • async functionrender: async func() -> list<u8>

    An async method.

  • static functionopen: static func(path: string) -> result<canvas, string>

    A static function.

  • static async functionload: static async func(url: string) -> result<canvas, string>

    A static async function.

  • get functiontitle: get() -> string

    A property with a getter and a setter.

  • set functiontitle: set(value: string)
  • get functionarea: get() -> u64

    A property with a getter alone.

  • static get functionmax-size: static get() -> u32

    A static property.

  • static set functionmax-size: static set(value: u32) -> result<_, string>

type signal

  • future

type eventually

  • future<result<string, error-context>>

type ticks

  • stream

type bytes

  • stream<u8>

type frames

type failure

  • error-context

Functions

async functionfetch: async func(url: string) -> result<list<u8>, error-context>

An async function.

functionwatch: func(path: string) -> tuple<stream<string>, future<result>>

A function that returns a stream and a future of its end.

functiontick: func()

A function with neither params nor results.

async functionwait: async func()

An async function with neither params nor results.

WIT

/// Futures, streams and error contexts, and async functions.
interface concurrency {
  use resources.{canvas};

  type signal = future;

  type eventually = future<result<string, error-context>>;

  type ticks = stream;

  type bytes = stream<u8>;

  type frames = stream<canvas>;

  type failure = error-context;

  /// An async function.
  fetch: async func(url: string) -> result<list<u8>, error-context>;

  /// A function that returns a stream and a future of its end.
  watch: func(path: string) -> tuple<stream<string>, future<result>>;

  /// A function with neither params nor results.
  tick: func();

  /// An async function with neither params nor results.
  wait: async func();
}