componentized

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

Imports each kind of world item.

Imports

interface inline

An inline interface.

use record point

from kitchen-sink:types/shapes@0.1.0

A point on a plane.

  • x: f64

    Across.

  • y: f64

    Down.

functionping: func(at: point) -> bool

use enum direction

from kitchen-sink:types/shapes@0.1.0

The cardinal directions.

  • north
  • east
  • south
  • west

type compass

A type defined in the world.

resource session

A world-level resource.

  • constructor functionconstructor()
  • functionend: func()

functionlog: func(message: string)

A function.

async functionsleep: async func(ms: u64)

An async function.

get functionvolume: get() -> u8

A property of the world.

set functionvolume: set(value: u8)

Exports

functionrun: func(args: list<string>) -> result

WIT

/// Imports each kind of world item.
world base {
  /// An interface, by its path in the package.
  import primitives;
  import containers;
  import shapes;
  /// An interface under a name of its own.
  import pictures: resources;
  /// An inline interface.
  import inline: interface {
    use shapes.{point};

    ping: func(at: point) -> bool;
  }
  import resources;
  use shapes.{direction};

  /// A type defined in the world.
  type compass = direction;

  /// A world-level resource.
  resource session {
    constructor();
    end: func();
  }
  /// A function.
  import log: func(message: string);
  /// An async function.
  import sleep: async func(ms: u64);
  /// A property of the world.
  import volume: get() -> u8;
  import volume: set(value: u8);

  export run: func(args: list<string>) -> result;
  export concurrency;
}