SchemaVisitor

com.digitalasset.transcode.schema.SchemaVisitor
See theSchemaVisitor companion object

This trait describes various types that a Daml package can contain. SchemaProcessor will use an implementation of this trait to feed types into the visitor. The visitor implementation should define SchemaVisitor.Type, which can be a Codec, or a Code-generator along with instructions how to process daml types. There are several use cases:

==Codecs==

To achieve the best performance, a codec should create a tree-like structure copying the structure of Daml types with each node processing corresponding daml type and delegating processing to the next node if it's a type container.

A codec should convert to and from DynamicValue instances. This allows to compose codecs from various protocols by combining them in com.digitalasset.transcode.Converter. For example, one code combine JsonCodec and ProtobufCodec to get direct conversions from json to Ledger API proto values and vice versa. Or one can compose JsonCodec and ScalaCodec, etc.

Note, that Dynamic Values omit some type information (like field names or variant names) to reduce memory allocation and serialization. This information is known to the codec at the type of construction and codecs are encouraged to cache it.

==Code generators==

Code generators can produce code snippets at each handler and combine them into a file or a set of files that can be used as generated source in the target language.

It is advisable to also generate a codec along with DTOs (Data Transfer Object) to allow for direct interoperability with other existing protocols (Json or Protobuf).

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Delegate[T, R]
trait Unit
trait WithResult[R]
trait CodecVisitor[T]

Members list

Type members

Types

type Result

Final result type

Final result type

Attributes

type Type

Visitor handler type for various DAML schema cases.

Visitor handler type for various DAML schema cases.

Attributes

Value members

Abstract methods

def application(value: Type, typeParams: Seq[TypeVarName], args: Seq[Type]): Type

Type Application

Type Application

Attributes

def bool: Type

Boolean

Boolean

Attributes

def collect(entities: Seq[Template[Type]]): Result
def constructor(id: Identifier, typeParams: Seq[TypeVarName], value: => Type): Type

Wrap type into addressable DataType

Wrap type into addressable DataType

Attributes

def contractId(template: Type): Type

Contract ID, parametrized with the processor for corresponding template

Contract ID, parametrized with the processor for corresponding template

Attributes

def date: Type

Date

Date

Attributes

def enumeration(cases: Seq[EnumConName]): Type

ADT, Sum type - special case, where there are only named constructors without arguments

ADT, Sum type - special case, where there are only named constructors without arguments

Attributes

def genMap(key: Type, value: Type): Type

Map with keys and values of any type

Map with keys and values of any type

Attributes

def int64: Type

8-byte Integer

8-byte Integer

Attributes

def list(elem: Type): Type

Sequence of elements

Sequence of elements

Attributes

def numeric(scale: Int): Type

Numeric with scale

Numeric with scale

Attributes

def optional(elem: Type): Type

Optional element

Optional element

Attributes

def party: Type

Party

Party

Attributes

def record(fields: Seq[(FieldName, Type)]): Type

ADT, Product type

ADT, Product type

Attributes

def text: Type

Text

Text

Attributes

def textMap(value: Type): Type

Map with keys of String/Text type

Map with keys of String/Text type

Attributes

Timestamp

Timestamp

Attributes

def unit: Type

Unit

Unit

Attributes

def variable(name: TypeVarName): Type

Type Variable.

Type Variable.

Codecs will use substitution, effectively replacing type variables with concrete types, while code generators will use type variable names.

Attributes

def variant(cases: Seq[(VariantConName, Type)]): Type

ADT, Sum type

ADT, Sum type

Attributes