Commit 39818c1 1 parent db9d8a7 commit 39818c1 Copy full SHA for 39818c1
File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ package schemadmt
2
+
3
+ import (
4
+ "github.com/ipld/go-ipld-prime/datamodel"
5
+ "github.com/ipld/go-ipld-prime/node/bindnode"
6
+ )
7
+
8
+ // ConcatenateSchemas returns a new schema DMT object containing the
9
+ // type declarations from both.
10
+ //
11
+ // As is usual for DMT form data, there is no check about the validity
12
+ // of the result yet; you'll need to apply `Compile` on the produced value
13
+ // to produce a usable compiled typesystem or to become certain that
14
+ // all references in the DMT are satisfied, etc.
15
+ func ConcatenateSchemas (a , b * Schema ) * Schema {
16
+ // The joy of having an intermediate form that's just regular data model:
17
+ // we can implement this by simply using data model "copy" operations,
18
+ // and the result is correct.
19
+ nb := Type .Schema .NewBuilder ()
20
+ if err := datamodel .Copy (bindnode .Wrap (a , Type .Schema .Type ()), nb ); err != nil {
21
+ panic (err )
22
+ }
23
+ if err := datamodel .Copy (bindnode .Wrap (b , Type .Schema .Type ()), nb ); err != nil {
24
+ panic (err )
25
+ }
26
+ return bindnode .Unwrap (nb .Build ()).(* Schema )
27
+ }
You can’t perform that action at this time.
0 commit comments