Documentation ¶
Index ¶
- func ConvertValues(n *parser.Node) ([]idl.Type, []any, error)
- type Argument
- type Blob
- type Data
- type DataId
- type Definition
- type Description
- type Field
- type Func
- type FuncAnnotation
- type Import
- type Method
- type Optional
- type Primitive
- type Principal
- type Record
- type Service
- type Tuple
- type Type
- type Variant
- type Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.
type Definition ¶
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 *parser.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.
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.
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.
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.
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.
type Principal ¶
type Principal struct{}
Principal is the common scheme to identify canisters, users, and other entities.
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; }