SpruceKit
SpruceID
  • 🌲SpruceKit Introduction
    • Decentralized Identity Overview
    • Glossary
  • ⚡Quickstart
  • SpruceKit Mobile
    • SpruceKit Showcase App
      • Installation
      • Getting Started
      • Issue a Showcase Credential
      • Present a Showcase Credential
    • SpruceKit Mobile SDK
      • Introduction
      • Core Components
        • StorageManager
        • KeyManager
        • CredentialPack
        • Card
        • IsoMdlPresentation
        • mDocReader/IsomDLReader
        • Document Scanner
      • SpruceKit iOS SDK
        • Installation
        • Build a Wallet
          • Accept a W3C VC
          • Present a W3C VC
          • Present mDL in-person/offline
          • Present an mDL over the internet
        • Build a Verifier
          • Verify a W3C VC
          • Verify an mDL in-person/offline
          • Verify an mDL over the internet
      • SpruceKit Android SDK
        • Installation
        • Build a Wallet
          • Accept a W3C VC
          • Present a W3C VC
          • Present an mDL in-person/offline
          • Present an mDL over the internet
        • Build a Verifier
          • Verify a W3C VC
          • Verify an mDL in-person/offline
          • Verify an mDL over the internet
  • Verifiable Digital Credentials
    • ⚙️DIDKit
      • Installation
      • Core Concepts
      • DID Methods
      • Runtime Configuration
      • Specifications and Dependencies
      • Quickstart
      • DIDKit Packages
        • Command Line Interface
        • HTTP Server
        • Rust Crate
        • C Interface
        • Java and Android
        • Python
        • Javascript
      • DIDKit Examples
        • Core Functions (CLI)
        • Core Functions (HTTP)
        • did-web in minutes
        • Batch Generation & Verification
    • 🪪ISO mDL
      • Quickstart
      • Core Concepts
      • User Guide
  • Schema Definition Language
    • 🔗TreeLDR
      • TreeLDR Quickstart
        • First Schema
        • Compilation into JSON Schema
        • Compilation into JSON-LD Context
        • Writing a Layout
        • Simple Rust Integration
      • Types
        • Literal Types
      • Layouts
        • Primitive Layouts
        • Literal Layouts
        • Enumeration
        • Array Layout
        • References
      • Compiling
        • Schema Definition Formats
          • JSON Schema
          • JSON-LD Context
          • Resource Description Framework (RDF)
        • Programming Languages
          • Compiling to Rust
      • RDF Vocabulary
      • 💡TreeLDR Basics
        • Types and Layouts
        • Properties
        • Syntax
  • Witness for Credential Claims
    • 🔭Rebase
      • Core Library
      • Rust Client/Witness SDK
      • WASM Client SDK
      • Simple "Basic Post" Schema
      • DNS Witness Flow Schema
  • References
    • Contributing
    • Code of Conduct
Powered by GitBook
On this page

Was this helpful?

  1. Schema Definition Language
  2. TreeLDR

Layouts

There are four different kind of layout definitions in TreeLDR:

Empty Layout

The empty layout is defined by simply declaring the name of the layout directly followed by a semicolon.

// Empty layout.
layout MyLayout for MyType;

Structure Layout

A structure layout is a list of fields each bound to a property of the layout's type.

// Structure layout.
layout MyLayout for MyType {
	property1 as fieldName1: Layout1,
	// ...
	propertyN as fieldNameN: LayoutN
}

The layout of each field is specified after a colon : using a layout expression.

Enumeration Layout

[To Do]

Layout Alias

Lastly, it is possible to define layout aliases. Such a layout is defined using a layout expression.

layout MyLayout = LayoutExpression;

Layout Expression

A layout expression is a composition of existing layouts by union, intersection, and restriction.

Union

The union between two or more layouts is expressed using the | operator.

LayoutA | ... | LayoutN

Under the hood, this implicitly defines an enumeration layout.

Intersection

The intersection between two or more layouts is expressed using the & operator.

LayoutA & ... & LayoutN

Range Restriction

Range restrictions are used to select a subset of a layout by restricting the range of one of its fields. Just like with types, there are two kinds of range restrictions: universal and existential.

A universal range restriction is built using the all keyword:

all someProperty as fieldName: RestrictedLayout

This denotes the layout of all instances such that all values of fieldName are instances of RestrictedLayout.

Similarly, the existential range restriction is built using the any keyword:

any someProperty as fieldName: RestrictionLayout

This denotes the layout of all instances such that at least one value of fieldName is an instance of RestrictedLayout.

Range restrictions are usually part of an intersection:

Layout & all someProperty as fieldName: RestrictionLayout
PreviousLiteral TypesNextPrimitive Layouts

Last updated 11 months ago

Was this helpful?

🔗