componentized/directory

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

kitchen-sink:extras/greeter@0.1.0

interface

Uses types from another package, one under a new name.

Types

use record point

from kitchen-sink:types/shapes@0.1.0

A point on a plane.

  • x: f64

    Across.

  • y: f64

    Down.

use enum heading

from kitchen-sink:types/shapes@0.1.0

The cardinal directions.

  • north
  • east
  • south
  • west

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>

Functions

functiongreet: func(name: string, at: point, facing: heading) -> string

Greets a point, facing a heading.

functiondraw: func(on: borrow<canvas>, name: string)

Draws a greeting.

WIT

/// Uses types from another package, one under a new name.
interface greeter {
  use kitchen-sink:types/shapes@0.1.0.{point, direction as heading};
  use kitchen-sink:types/resources@0.1.0.{canvas};

  /// Greets a point, facing a heading.
  greet: func(name: string, at: point, facing: heading) -> string;

  /// Draws a greeting.
  draw: func(on: borrow<canvas>, name: string);
}