github.com/storacha/go-ucanto@v0.7.2/core/delegation/datamodel/archive.go (about)

     1  package datamodel
     2  
     3  import (
     4  	_ "embed"
     5  	"fmt"
     6  	"sync"
     7  
     8  	"github.com/ipld/go-ipld-prime"
     9  	"github.com/ipld/go-ipld-prime/schema"
    10  )
    11  
    12  //go:embed archive.ipldsch
    13  var archive []byte
    14  
    15  var (
    16  	once sync.Once
    17  	ts   *schema.TypeSystem
    18  	err  error
    19  )
    20  
    21  func mustLoadSchema() *schema.TypeSystem {
    22  	once.Do(func() {
    23  		ts, err = ipld.LoadSchemaBytes(archive)
    24  	})
    25  	if err != nil {
    26  		panic(fmt.Errorf("failed to load IPLD schema: %w", err))
    27  	}
    28  	return ts
    29  }
    30  
    31  func Type() schema.Type {
    32  	return mustLoadSchema().TypeByName("Archive")
    33  }
    34  
    35  type ArchiveModel struct {
    36  	Ucan0_9_1 ipld.Link
    37  }