com.digitalasset.transcode.schema

Members list

Type members

Classlikes

case class Choice[Type](name: ChoiceName, consuming: Boolean, argument: Type, result: Type)

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ChoiceName

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
ChoiceName.type
trait CodecVisitor[T] extends WithResult[Dictionary[Codec[T]]]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object CodecVisitor

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
object Debug

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Debug.type
sealed trait Descriptor(using x$1: Name) extends HasDescriptor

Compile-time representation of Schema. There are 4 main types of descriptors:

Compile-time representation of Schema. There are 4 main types of descriptors:

  • '''Algebraic Data Types''': Record, Variant, Enumeration.
  • '''Traversables''': List, Optional, TextMap, GenMap
  • '''Primitive Types''': Unit, Bool, Text, Int64, Numeric, Timestamp, Date, Party, ContractId
  • '''Type Constructors''' and Generic Types: Constructor, Application, Variable

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Adt
class Enumeration
class Record
class Variant
class Application
class Constructor
trait Primitive
object Bool
class ContractId
object Date
object Int64
class Numeric
object Party
object Text
object Timestamp
object Unit
trait Traversable
class GenMap
class List
class Optional
class TextMap
class Variable
Show all
object Descriptor

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Descriptor.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case class Dictionary[T](entities: Seq[Template[T]], strictPackageMatching: Boolean)

Dictionary of templates, keys, choice arguments and choice results.

Dictionary of templates, keys, choice arguments and choice results.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Dictionary

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Dictionary.type
object DynamicValue

Dynamic types are represented by opaque types to reduce memory allocations during transformation from one codec to another.

Dynamic types are represented by opaque types to reduce memory allocations during transformation from one codec to another.

There are 3 kinds of possible dynamic values:

  • ADTs: records or variants. These are fixed in size, and are containers to other types. These types are addressable and have identifiers. There are special cases: enums and wrapped types.
  • Traversables: lists, maps, optionals. These are variable in size and are containers to other types.
  • Primitives: primitive scalar types.

Codecs and code-generations should be constructed in such a way that ADTs and Traversables expecting other underlying dynamic values in processing routines should know exactly what underlying values they expect. The unwrapping of dynamic value and casting should be safe then. SchemaProcessor takes care of constructing a tree of type processors and injects correct underlying processors where needed. See examples of how this is used in codecs: JSON and Grpc and code-gens: Java and Scala.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Descriptor
trait Adt
class Enumeration
class Record
class Variant
class Application
class Constructor
trait Primitive
object Bool
class ContractId
object Date
object Int64
class Numeric
object Party
object Text
object Timestamp
object Unit
trait Traversable
class GenMap
class List
class Optional
class TextMap
class Variable
Show all
final case class Identifier(packageId: PackageId, packageName: PackageName, packageVersion: PackageVersion, moduleName: ModuleName, entityName: EntityName)

Tuple of Package ID, Module Name and Entity Name uniquely identify a template or a choice.

Tuple of Package ID, Module Name and Entity Name uniquely identify a template or a choice.

Tuple of Package Name, Module Name and Entity Name identify "equal in essence" entities, i.e. templates or choices that could be the results of upgrades of the same ancestor and therefore backward/forward compatible with each other This tuple will be used in equality checks of Maps, etc.

Package Version is a string that can be compared using SemVer rules

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Identifier

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Identifier.type
trait IdentifierFilter extends Identifier => Boolean

Attributes

Companion
object
Supertypes
trait Identifier => Boolean
class Object
trait Matchable
class Any
Self type

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object Pickler extends PicklerHelper

Attributes

Supertypes
trait PicklerHelper
class Object
trait Matchable
class Any
Self type
Pickler.type
object Schema

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Schema.type

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:

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
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Delegate[T, R]
trait Unit
trait WithResult[R]
trait CodecVisitor[T]
object SchemaVisitor

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
case class Template[Type](templateId: Identifier, payload: Type, key: Option[Type], isInterface: Boolean, implements: Seq[Identifier], choices: Seq[Choice[Type]])

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Types

opaque type ChoiceName
opaque type EntityName
opaque type EnumConName
opaque type FieldName
opaque type ModuleName
opaque type PackageId
opaque type PackageName
opaque type PackageVersion
opaque type TypeVarName
opaque type VariantConName

Value members

Concrete methods

def ChoiceName(value: String): ChoiceName
def EntityName(value: String): EntityName
def EnumConName(value: String): EnumConName
def FieldName(value: String): FieldName
def ModuleName(value: String): ModuleName
def PackageId(value: String): PackageId
def PackageName(value: String): PackageName
def PackageVersion(value: String): PackageVersion
def TypeVarName(value: String): TypeVarName
def VariantConName(value: String): VariantConName

Extensions

Extensions

extension (value: PackageId)
def packageId: String
extension (value: PackageName)
def packageName: String
extension (value: PackageVersion)
def packageVersion: String
extension (value: ModuleName)
def moduleName: String
extension (value: EntityName)
def entityName: String
extension (value: ChoiceName)
def choiceName: String
extension (value: TypeVarName)
def typeVarName: String
extension (value: FieldName)
def fieldName: String
extension (value: EnumConName)
def enumConName: String
extension (value: VariantConName)
def variantConName: String