Resources and each kind of function on them.
Types
resource token
A resource with no functions.
resource canvas
A resource with every kind of member.
constructor(width: u32, height: u32)Makes an empty canvas.
plot: func(at: point, color: list<u8, 4>)A method.
copy-from: func(other: borrow<canvas>) -> result<_, string>A method that borrows another canvas.
snapshot: func() -> canvasA method that hands back a resource it owns.
render: async func() -> list<u8>An async method.
open: static func(path: string) -> result<canvas, string>A static function.
load: static async func(url: string) -> result<canvas, string>A static async function.
title: get() -> stringA property with a getter and a setter.
title: set(value: string)area: get() -> u64A property with a getter alone.
max-size: static get() -> u32A static property.
max-size: static set(value: u32) -> result<_, string>
Functions
issue: func() -> token
A free function that names the resource without own.
WIT
/// Resources and each kind of function on them.
interface resources {
use shapes.{point};
/// A resource with no functions.
resource token;
/// A resource with every kind of member.
resource canvas {
/// Makes an empty canvas.
constructor(width: u32, height: u32);
/// A method.
plot: func(at: point, color: list<u8, 4>);
/// A method that borrows another canvas.
copy-from: func(other: borrow<canvas>) -> result<_, string>;
/// A method that hands back a resource it owns.
snapshot: func() -> canvas;
/// An async method.
render: async func() -> list<u8>;
/// A static function.
open: static func(path: string) -> result<canvas, string>;
/// A static async function.
load: static async func(url: string) -> result<canvas, string>;
/// A property with a getter and a setter.
title: get() -> string;
title: set(value: string);
/// A property with a getter alone.
area: get() -> u64;
/// A static property.
max-size: static get() -> u32;
max-size: static set(value: u32) -> result<_, string>;
}
/// A free function taking and returning resources.
merge: func(a: canvas, b: borrow<canvas>) -> canvas;
/// A free function that names the resource without `own`.
issue: func() -> token;
}