componentized

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

Includes another world, renaming one of its items.

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()

functiontrace: 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

async functionserve: async func() -> result<_, string>

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

WIT

/// Includes another world, renaming one of its items.
world extended {
  @unstable(feature = experimental)
  import gates;
  /// 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 trace: 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 serve: async func() -> result<_, string>;
  export run: func(args: list<string>) -> result;
  export concurrency;
}