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
  3. Layouts

References

A reference is a special layout that can be used to avoid directly embedding a value by instead embedding only an identifier to the value.

A reference layout can be built using the & character, followed by the type of reference.

&Type

For instance, we define here the Person type where each parent will be referenced in its default layout using the &Person layout.

type Person {
	name: required xs:string,
	parent: multiple &Person
}

Export

A reference layout is exported into any type that can store both an IRI or blank node identifier. In most languages, it will be a string.

For instance, the above layout will be exported into the following JSON Schema:

{
	"type": "object",
	"properties": {
		"name": {
			"type": "string"
		},
		"parent": {
			"type": "array",
			"item": {
				"type": "string"
			}
		}
	},
	"required": [
		"name"
	]
}

When the language permits it, a more precise type will be used. For instance in Rust, the Id type of the treeldr-rust-prelude will be used by default, which is defined as follows:

use iref::IriBuf;
use rdf_types::BlankIdBuf;

pub enum Id {
	Blank(BlankIdBuf),
	Iri(IriBuf)
}

As a consequence, the following Rust type definition is generated for Person:

pub enum Person {
	name: String,
	parent: BTreeSet<Id>
}
PreviousArray LayoutNextCompiling

Last updated 1 year ago

Was this helpful?

🔗