did

package
v0.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertValues

func ConvertValues(n *ast.Node) ([]idl.Type, []any, error)

Types

type Argument

type Argument struct {
	// Name only serves documentation purposes and have no semantic significance.
	Name *string
	// Data is the data type of the argument.
	Data Data
}

Argument describes the argument types of a Field.

func (Argument) String

func (a Argument) String() string

type Blob

type Blob struct{}

Blob can be used for binary data, that is, sequences of bytes.

func (Blob) String

func (b Blob) String() string

type Data

type Data interface {
	fmt.Stringer
	// contains filtered or unexported methods
}

Data is the content of message arguments and results.

type DataId

type DataId string

DataId is an id reference to a data type.

func (DataId) String

func (i DataId) String() string

type Definition

type Definition interface {
	fmt.Stringer
	// contains filtered or unexported methods
}

Definition represents an imports or type definition.

type Description

type Description struct {
	// Definitions is the sequence of import and type definitions.
	Definitions []Definition
	// Services is a list of service declarations.
	Services []Service
}

Description represents the interface description of a program. An interface description consists of a sequence of imports and type definitions, possibly followed by a service declaration.

func ConvertDescription

func ConvertDescription(n *ast.Node) Description

func (Description) String

func (p Description) String() string

type Field

type Field struct {
	// Nat is the field id.
	// e.g. 0 : nat
	Nat *big.Int
	// Name is the name of the field.
	// e.g. name : text
	Name *string

	// Data is a single value of specified data type that is carried.
	Data *Data

	// Only in variants.
	NatData  *big.Int
	NameData *string
}

Field The order in which fields are specified is immaterial.

func (Field) String

func (f Field) String() string

type Func

type Func struct {
	// ArgTypes is the list of parameters.
	ArgTypes Tuple
	// ResTypes is the list of results.
	ResTypes Tuple
	// Annotation indicates an (optional) invocation method.
	Annotation *FuncAnnotation
}

Func indicates the function’s signature (argument and results types, annotations), and values of this type are references to functions with that signature.

func (Func) String

func (f Func) String() string

type FuncAnnotation

type FuncAnnotation string

FuncAnnotation represents a function annotation.

const (
	// AnnOneWay indicates that this function returns no response, intended for
	// fire-and-forget scenarios.
	AnnOneWay FuncAnnotation = "oneway"
	// AnnQuery indicates that the referenced function is a query method, meaning
	// it does not alter the state of its canister, and that it can be invoked
	// using the cheaper “query call” mechanism.
	AnnQuery FuncAnnotation = "query"
)

type Import

type Import struct {
	Text string
}

Import represents an import declarations from another file.

func (Import) String

func (i Import) String() string

type Method

type Method struct {
	// Name describes the method.
	Name string

	// Func is a function type describing its signature.
	Func *Func
	// ID is a reference to a type definition naming a function reference type.
	// It is NOT possible to have both a function type and a reference.
	ID *string
}

Method is a public method of a service.

func (Method) String

func (m Method) String() string

type Optional

type Optional struct {
	Data Data
}

Optional is used to express that some value is optional, meaning that data might be present as some value of type t, or might be absent as the value null.

func (Optional) String

func (o Optional) String() string

type Primitive

type Primitive string

Primitive describes the possible forms of primitive data.

func (Primitive) String

func (p Primitive) String() string

type Principal

type Principal struct{}

Principal is the common scheme to identify canisters, users, and other entities.

func (Principal) String

func (p Principal) String() string

type Record

type Record []Field

Record a collection of labeled values.

func (Record) String

func (r Record) String() string

type Service

type Service struct {
	// ID represents the optional name given to the service. This only serves as documentation.
	ID *string

	// Methods is the list of methods that the service provides.
	Methods []Method
	// MethodId is the reference to the name of a type definition for an actor reference type.
	// It is NOT possible to have both a list of methods and a reference.
	MethodId *string
}

Service can be used to declare the complete interface of a service. A service is a standalone actor on the platform that can communicate with other services via sending and receiving messages. Messages are sent to a service by invoking one of its methods, i.e., functions that the service provides.

Example:

service : {
	addUser : (name : text, age : nat8) -> (id : nat64);
	userName : (id : nat64) -> (text) query;
	userAge : (id : nat64) -> (nat8) query;
	deleteUser : (id : nat64) -> () oneway;
}

func (Service) String

func (a Service) String() string

type Tuple

type Tuple []Argument

Tuple represents one or more arguments.

func (Tuple) String

func (t Tuple) String() string

type Type

type Type struct {
	Id   string
	Data Data
}

Type represents a named type definition.

func (Type) String

func (t Type) String() string

type Variant

type Variant []Field

Variant represents a value that is from exactly one of the given cases, or tags.

func (Variant) String

func (v Variant) String() string

type Vector

type Vector struct {
	Data Data
}

Vector represents vectors (sequences, lists, arrays). e.g. 'vec bool', 'vec nat8', 'vec vec text', etc

func (Vector) String

func (v Vector) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL