TUN-528: Move cloudflared into a separate repo

This commit is contained in:
Areg Harutyunyan
2018-05-01 18:45:06 -05:00
parent e8c621a648
commit d06fc520c7
4726 changed files with 1763680 additions and 0 deletions

9
vendor/zombiezen.com/go/capnproto2/std/BUILD.bazel generated vendored Normal file
View File

@@ -0,0 +1,9 @@
package(default_visibility = ["//visibility:public"])
filegroup(
name = "schema",
srcs = glob([
"*.capnp",
"capnp/*.capnp",
]),
)

71
vendor/zombiezen.com/go/capnproto2/std/capnp/README.md generated vendored Normal file
View File

@@ -0,0 +1,71 @@
This directory contains go packages for all of the capnproto
schemas that ship with capnproto itself. They are generated with
the help of `./gen.sh`. Though some manual modifications have been made
to the schema to correct name collisions (See below).
# `./gen.sh` Usage
Executing:
./gen.sh import /path/to/schemas
Will copy all the `*.capnp` files from the given directory into this
directory, and add annotations to them specifying package names and
import paths for `capnpc-go`.
./gen.sh compile
Will generate go packages for each of the schemas in the current
directory.
./gen.sh clean-go
Will remove all generated go source files from this directory. Finally,
./gen.sh clean-all
Will remove both the go source files and the imported schemas.
`gen.sh` does some name mangling to ensure that the generated packages
are actually legal go. However, this is not meant to be a
general-purpose solution; it is only intended to work for the base
schemas.
# Extra Annotations
Under certain circumstances, `capnpc-go` will sometimes generate illegal
go code. As an example, if two declarations `Foo` and `foo` exist in the
schema, `capnpc-go` will capitalize the latter so that it will be
exported, which will cause a name collision.
To address this kind of issue, some of the schema have been manually
modified after importing, adding `$Go.name` annotations which prevent
these errors.
# Versions
The schemas checked in to this repository are those in capnproto commit
ad4079b (master at the time of writing). Unfortunately, the stable
release is *very* old, and some schemas out in the wild (notably
sandstorm) have started expecting more recent versions of the base
schemas.
# Directory Structure
The directory structure of this repository is designed such that when
compiling other schema, it should be sufficient to execute:
capnp compile -I ${path_to_this_repository}/std -ogo ${schama_name}.capnp
And have the `$import` statements in existing schema "just work."
To achieve this, the base schemas themselves are stored as
`/std/capnp/${schema_name}.capnp`. The generated go source files are
stored in a subdirectory, to make them their own package:
`/std/capnp/${mangled_schema_name}/${mangled_schema_name}.capnp.go`.
In addition to the upstream base schemas, we also ship a schema
`/std/go.capnp`, which contains annotations used by `go-capnpc`. Its
usage is described in the top-level README. The generated source is
placed in the root of the repository, making it part of the go package
`zombiezen.com/go/capnproto2`.

29
vendor/zombiezen.com/go/capnproto2/std/capnp/c++.capnp generated vendored Normal file
View File

@@ -0,0 +1,29 @@
# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
# Licensed under the MIT License:
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
@0xbdf87d7bb8304e81;
$namespace("capnp::annotations");
annotation namespace(file): Text;
annotation name(field, enumerant, struct, enum, interface, method, param, group, union): Text;
using Go = import "/go.capnp";
$Go.package("cxx");
$Go.import("zombiezen.com/go/capnproto2/std/capnp/cxx");

View File

@@ -0,0 +1,9 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["c++.capnp.go"],
importpath = "zombiezen.com/go/capnproto2/std/capnp/cxx",
visibility = ["//visibility:public"],
deps = ["//schemas:go_default_library"],
)

View File

@@ -0,0 +1,25 @@
// Code generated by capnpc-go. DO NOT EDIT.
package cxx
import (
schemas "zombiezen.com/go/capnproto2/schemas"
)
const Namespace = uint64(0xb9c6f99ebf805f2c)
const Name = uint64(0xf264a779fef191ce)
const schema_bdf87d7bb8304e81 = "x\xda\x12\x08u`2d\x15gb`\x08\x94`e" +
"\xfb\xaf\x13\xdf\xb0\x7f\xde\xcfc;\x19\x02\xb9X\x19\xff" +
"7\xfa\x19\xec\xa8\xae\xfd\xb1\x97\x81\x81Q\xf0\xe3\"\xc1" +
"\x9f\xec\x0c\x0c\x81_\x98\x19\x19\x18\xff\x9f\x9b\xf8\xf1_" +
"\xe5\xf2\x94O\x0c\x17\xb9X\xff\xb0\xa3(|Z%\xf8" +
"\x12\xa4\xf0\x093#\x83\xee\xffdmm\xbd\xe4\xc4\x82" +
"<\xc6\x02\xab\xbc\xc4\xdc\xd4\xe2\x02\xf6\xc4\xe4\xd4\x00F" +
"FF\x1e\x06&\xb8$\x83=D\x16*\x0e\x08\x00\x00" +
"\xff\xffE\x881\xaa"
func init() {
schemas.Register(schema_bdf87d7bb8304e81,
0xb9c6f99ebf805f2c,
0xf264a779fef191ce)
}

83
vendor/zombiezen.com/go/capnproto2/std/capnp/gen.sh generated vendored Executable file
View File

@@ -0,0 +1,83 @@
#!/bin/bash
infer_package_name() {
# Convert the filename $1 to a package name. We munge the name as follows:
#
# 1. strip off the capnp file extension and dirname
# 2. remove dashes
# 3. convert '+' to 'x'. This is really just for c++.capnp, but it's not
# any easier to special case it.
printf '%s' "$(basename $1)" | sed 's/\.capnp$// ; s/-//g ; s/+/x/g'
}
gen_annotated_schema() {
# Copy the schema from file "$1" to the current directory, and add
# appropriate $Go annotations.
infile="$1"
outfile="$(basename $infile)"
cp "$infile" "$outfile" || return 1
package_name="$(infer_package_name $outfile)"
cat >> "$outfile" << EOF
using Go = import "/go.capnp";
\$Go.package("$package_name");
\$Go.import("zombiezen.com/go/capnproto2/std/capnp/$package_name");
EOF
}
gen_go_src() {
# Generate go source code from the schema file $1. Create the package
# directory if necessary.
file="$1"
package_name="$(infer_package_name $file)"
mkdir -p $package_name || return 1
capnp compile -I"$(dirname $PWD)" -ogo:$package_name $file
}
usage() {
echo "Usage:"
echo ""
echo " $0 import <path/to/schema/files>"
echo " $0 compile # Generate go source files"
echo " $0 clean-go # Remove go source files"
echo " $0 clean-all # Remove go source files and imported schemas"
}
# do_* implements the corresponding subcommand described in usage's output.
do_import() {
input_dir="$1"
for file in $input_dir/*.capnp; do
gen_annotated_schema "$file" || return 1
done
}
do_compile() {
for file in *.capnp; do
gen_go_src "$file" || return 1
done
}
do_clean_go() {
find "$(dirname $0)" -name '*.capnp.go' -delete
find "$(dirname $0)" -type d -empty -delete
}
do_clean_all() {
do_clean_go
find "$(dirname $0)" -name '*.capnp' -delete
}
eq_or_usage() {
# If "$1" is not equal to "$2", call usage and exit.
if [ ! $1 = $2 ] ; then
usage
exit 1
fi
}
case "$1" in
import) eq_or_usage $# 2; do_import "$2" ;;
compile) eq_or_usage $# 1; do_compile ;;
clean-go) eq_or_usage $# 1; do_clean_go ;;
clean-all) eq_or_usage $# 1; do_clean_all ;;
*) usage; exit 1 ;;
esac

View File

@@ -0,0 +1,61 @@
# Copyright (c) 2015 Sandstorm Development Group, Inc. and contributors
# Licensed under the MIT License:
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
@0x8ef99297a43a5e34;
$import "/capnp/c++.capnp".namespace("capnp");
struct JsonValue {
union {
null @0 :Void;
boolean @1 :Bool;
number @2 :Float64;
string @3 :Text $Go.name("string_");
array @4 :List(JsonValue);
object @5 :List(Field);
# Standard JSON values.
call @6 :Call;
# Non-standard: A "function call", applying a named function (named by a single identifier)
# to a parameter list. Examples:
#
# BinData(0, "Zm9vCg==")
# ISODate("2015-04-15T08:44:50.218Z")
#
# Mongo DB users will recognize the above as exactly the syntax Mongo uses to represent BSON
# "binary" and "date" types in text, since JSON has no analog of these. This is basically the
# reason this extension exists. We do NOT recommend using `call` unless you specifically need
# to be compatible with some silly format that uses this syntax.
}
struct Field {
name @0 :Text;
value @1 :JsonValue;
}
struct Call {
function @0 :Text;
params @1 :List(JsonValue);
}
}
using Go = import "/go.capnp";
$Go.package("json");
$Go.import("zombiezen.com/go/capnproto2/std/capnp/json");

View File

@@ -0,0 +1,13 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["json.capnp.go"],
importpath = "zombiezen.com/go/capnproto2/std/capnp/json",
visibility = ["//visibility:public"],
deps = [
"//:go_default_library",
"//encoding/text:go_default_library",
"//schemas:go_default_library",
],
)

View File

@@ -0,0 +1,494 @@
// Code generated by capnpc-go. DO NOT EDIT.
package json
import (
math "math"
strconv "strconv"
capnp "zombiezen.com/go/capnproto2"
text "zombiezen.com/go/capnproto2/encoding/text"
schemas "zombiezen.com/go/capnproto2/schemas"
)
type JsonValue struct{ capnp.Struct }
type JsonValue_Which uint16
const (
JsonValue_Which_null JsonValue_Which = 0
JsonValue_Which_boolean JsonValue_Which = 1
JsonValue_Which_number JsonValue_Which = 2
JsonValue_Which_string_ JsonValue_Which = 3
JsonValue_Which_array JsonValue_Which = 4
JsonValue_Which_object JsonValue_Which = 5
JsonValue_Which_call JsonValue_Which = 6
)
func (w JsonValue_Which) String() string {
const s = "nullbooleannumberstring_arrayobjectcall"
switch w {
case JsonValue_Which_null:
return s[0:4]
case JsonValue_Which_boolean:
return s[4:11]
case JsonValue_Which_number:
return s[11:17]
case JsonValue_Which_string_:
return s[17:24]
case JsonValue_Which_array:
return s[24:29]
case JsonValue_Which_object:
return s[29:35]
case JsonValue_Which_call:
return s[35:39]
}
return "JsonValue_Which(" + strconv.FormatUint(uint64(w), 10) + ")"
}
// JsonValue_TypeID is the unique identifier for the type JsonValue.
const JsonValue_TypeID = 0x8825ffaa852cda72
func NewJsonValue(s *capnp.Segment) (JsonValue, error) {
st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 16, PointerCount: 1})
return JsonValue{st}, err
}
func NewRootJsonValue(s *capnp.Segment) (JsonValue, error) {
st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 16, PointerCount: 1})
return JsonValue{st}, err
}
func ReadRootJsonValue(msg *capnp.Message) (JsonValue, error) {
root, err := msg.RootPtr()
return JsonValue{root.Struct()}, err
}
func (s JsonValue) String() string {
str, _ := text.Marshal(0x8825ffaa852cda72, s.Struct)
return str
}
func (s JsonValue) Which() JsonValue_Which {
return JsonValue_Which(s.Struct.Uint16(0))
}
func (s JsonValue) SetNull() {
s.Struct.SetUint16(0, 0)
}
func (s JsonValue) Boolean() bool {
if s.Struct.Uint16(0) != 1 {
panic("Which() != boolean")
}
return s.Struct.Bit(16)
}
func (s JsonValue) SetBoolean(v bool) {
s.Struct.SetUint16(0, 1)
s.Struct.SetBit(16, v)
}
func (s JsonValue) Number() float64 {
if s.Struct.Uint16(0) != 2 {
panic("Which() != number")
}
return math.Float64frombits(s.Struct.Uint64(8))
}
func (s JsonValue) SetNumber(v float64) {
s.Struct.SetUint16(0, 2)
s.Struct.SetUint64(8, math.Float64bits(v))
}
func (s JsonValue) String_() (string, error) {
if s.Struct.Uint16(0) != 3 {
panic("Which() != string_")
}
p, err := s.Struct.Ptr(0)
return p.Text(), err
}
func (s JsonValue) HasString_() bool {
if s.Struct.Uint16(0) != 3 {
return false
}
p, err := s.Struct.Ptr(0)
return p.IsValid() || err != nil
}
func (s JsonValue) String_Bytes() ([]byte, error) {
p, err := s.Struct.Ptr(0)
return p.TextBytes(), err
}
func (s JsonValue) SetString_(v string) error {
s.Struct.SetUint16(0, 3)
return s.Struct.SetText(0, v)
}
func (s JsonValue) Array() (JsonValue_List, error) {
if s.Struct.Uint16(0) != 4 {
panic("Which() != array")
}
p, err := s.Struct.Ptr(0)
return JsonValue_List{List: p.List()}, err
}
func (s JsonValue) HasArray() bool {
if s.Struct.Uint16(0) != 4 {
return false
}
p, err := s.Struct.Ptr(0)
return p.IsValid() || err != nil
}
func (s JsonValue) SetArray(v JsonValue_List) error {
s.Struct.SetUint16(0, 4)
return s.Struct.SetPtr(0, v.List.ToPtr())
}
// NewArray sets the array field to a newly
// allocated JsonValue_List, preferring placement in s's segment.
func (s JsonValue) NewArray(n int32) (JsonValue_List, error) {
s.Struct.SetUint16(0, 4)
l, err := NewJsonValue_List(s.Struct.Segment(), n)
if err != nil {
return JsonValue_List{}, err
}
err = s.Struct.SetPtr(0, l.List.ToPtr())
return l, err
}
func (s JsonValue) Object() (JsonValue_Field_List, error) {
if s.Struct.Uint16(0) != 5 {
panic("Which() != object")
}
p, err := s.Struct.Ptr(0)
return JsonValue_Field_List{List: p.List()}, err
}
func (s JsonValue) HasObject() bool {
if s.Struct.Uint16(0) != 5 {
return false
}
p, err := s.Struct.Ptr(0)
return p.IsValid() || err != nil
}
func (s JsonValue) SetObject(v JsonValue_Field_List) error {
s.Struct.SetUint16(0, 5)
return s.Struct.SetPtr(0, v.List.ToPtr())
}
// NewObject sets the object field to a newly
// allocated JsonValue_Field_List, preferring placement in s's segment.
func (s JsonValue) NewObject(n int32) (JsonValue_Field_List, error) {
s.Struct.SetUint16(0, 5)
l, err := NewJsonValue_Field_List(s.Struct.Segment(), n)
if err != nil {
return JsonValue_Field_List{}, err
}
err = s.Struct.SetPtr(0, l.List.ToPtr())
return l, err
}
func (s JsonValue) Call() (JsonValue_Call, error) {
if s.Struct.Uint16(0) != 6 {
panic("Which() != call")
}
p, err := s.Struct.Ptr(0)
return JsonValue_Call{Struct: p.Struct()}, err
}
func (s JsonValue) HasCall() bool {
if s.Struct.Uint16(0) != 6 {
return false
}
p, err := s.Struct.Ptr(0)
return p.IsValid() || err != nil
}
func (s JsonValue) SetCall(v JsonValue_Call) error {
s.Struct.SetUint16(0, 6)
return s.Struct.SetPtr(0, v.Struct.ToPtr())
}
// NewCall sets the call field to a newly
// allocated JsonValue_Call struct, preferring placement in s's segment.
func (s JsonValue) NewCall() (JsonValue_Call, error) {
s.Struct.SetUint16(0, 6)
ss, err := NewJsonValue_Call(s.Struct.Segment())
if err != nil {
return JsonValue_Call{}, err
}
err = s.Struct.SetPtr(0, ss.Struct.ToPtr())
return ss, err
}
// JsonValue_List is a list of JsonValue.
type JsonValue_List struct{ capnp.List }
// NewJsonValue creates a new list of JsonValue.
func NewJsonValue_List(s *capnp.Segment, sz int32) (JsonValue_List, error) {
l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 16, PointerCount: 1}, sz)
return JsonValue_List{l}, err
}
func (s JsonValue_List) At(i int) JsonValue { return JsonValue{s.List.Struct(i)} }
func (s JsonValue_List) Set(i int, v JsonValue) error { return s.List.SetStruct(i, v.Struct) }
func (s JsonValue_List) String() string {
str, _ := text.MarshalList(0x8825ffaa852cda72, s.List)
return str
}
// JsonValue_Promise is a wrapper for a JsonValue promised by a client call.
type JsonValue_Promise struct{ *capnp.Pipeline }
func (p JsonValue_Promise) Struct() (JsonValue, error) {
s, err := p.Pipeline.Struct()
return JsonValue{s}, err
}
func (p JsonValue_Promise) Call() JsonValue_Call_Promise {
return JsonValue_Call_Promise{Pipeline: p.Pipeline.GetPipeline(0)}
}
type JsonValue_Field struct{ capnp.Struct }
// JsonValue_Field_TypeID is the unique identifier for the type JsonValue_Field.
const JsonValue_Field_TypeID = 0xc27855d853a937cc
func NewJsonValue_Field(s *capnp.Segment) (JsonValue_Field, error) {
st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2})
return JsonValue_Field{st}, err
}
func NewRootJsonValue_Field(s *capnp.Segment) (JsonValue_Field, error) {
st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2})
return JsonValue_Field{st}, err
}
func ReadRootJsonValue_Field(msg *capnp.Message) (JsonValue_Field, error) {
root, err := msg.RootPtr()
return JsonValue_Field{root.Struct()}, err
}
func (s JsonValue_Field) String() string {
str, _ := text.Marshal(0xc27855d853a937cc, s.Struct)
return str
}
func (s JsonValue_Field) Name() (string, error) {
p, err := s.Struct.Ptr(0)
return p.Text(), err
}
func (s JsonValue_Field) HasName() bool {
p, err := s.Struct.Ptr(0)
return p.IsValid() || err != nil
}
func (s JsonValue_Field) NameBytes() ([]byte, error) {
p, err := s.Struct.Ptr(0)
return p.TextBytes(), err
}
func (s JsonValue_Field) SetName(v string) error {
return s.Struct.SetText(0, v)
}
func (s JsonValue_Field) Value() (JsonValue, error) {
p, err := s.Struct.Ptr(1)
return JsonValue{Struct: p.Struct()}, err
}
func (s JsonValue_Field) HasValue() bool {
p, err := s.Struct.Ptr(1)
return p.IsValid() || err != nil
}
func (s JsonValue_Field) SetValue(v JsonValue) error {
return s.Struct.SetPtr(1, v.Struct.ToPtr())
}
// NewValue sets the value field to a newly
// allocated JsonValue struct, preferring placement in s's segment.
func (s JsonValue_Field) NewValue() (JsonValue, error) {
ss, err := NewJsonValue(s.Struct.Segment())
if err != nil {
return JsonValue{}, err
}
err = s.Struct.SetPtr(1, ss.Struct.ToPtr())
return ss, err
}
// JsonValue_Field_List is a list of JsonValue_Field.
type JsonValue_Field_List struct{ capnp.List }
// NewJsonValue_Field creates a new list of JsonValue_Field.
func NewJsonValue_Field_List(s *capnp.Segment, sz int32) (JsonValue_Field_List, error) {
l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}, sz)
return JsonValue_Field_List{l}, err
}
func (s JsonValue_Field_List) At(i int) JsonValue_Field { return JsonValue_Field{s.List.Struct(i)} }
func (s JsonValue_Field_List) Set(i int, v JsonValue_Field) error {
return s.List.SetStruct(i, v.Struct)
}
func (s JsonValue_Field_List) String() string {
str, _ := text.MarshalList(0xc27855d853a937cc, s.List)
return str
}
// JsonValue_Field_Promise is a wrapper for a JsonValue_Field promised by a client call.
type JsonValue_Field_Promise struct{ *capnp.Pipeline }
func (p JsonValue_Field_Promise) Struct() (JsonValue_Field, error) {
s, err := p.Pipeline.Struct()
return JsonValue_Field{s}, err
}
func (p JsonValue_Field_Promise) Value() JsonValue_Promise {
return JsonValue_Promise{Pipeline: p.Pipeline.GetPipeline(1)}
}
type JsonValue_Call struct{ capnp.Struct }
// JsonValue_Call_TypeID is the unique identifier for the type JsonValue_Call.
const JsonValue_Call_TypeID = 0x9bbf84153dd4bb60
func NewJsonValue_Call(s *capnp.Segment) (JsonValue_Call, error) {
st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2})
return JsonValue_Call{st}, err
}
func NewRootJsonValue_Call(s *capnp.Segment) (JsonValue_Call, error) {
st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2})
return JsonValue_Call{st}, err
}
func ReadRootJsonValue_Call(msg *capnp.Message) (JsonValue_Call, error) {
root, err := msg.RootPtr()
return JsonValue_Call{root.Struct()}, err
}
func (s JsonValue_Call) String() string {
str, _ := text.Marshal(0x9bbf84153dd4bb60, s.Struct)
return str
}
func (s JsonValue_Call) Function() (string, error) {
p, err := s.Struct.Ptr(0)
return p.Text(), err
}
func (s JsonValue_Call) HasFunction() bool {
p, err := s.Struct.Ptr(0)
return p.IsValid() || err != nil
}
func (s JsonValue_Call) FunctionBytes() ([]byte, error) {
p, err := s.Struct.Ptr(0)
return p.TextBytes(), err
}
func (s JsonValue_Call) SetFunction(v string) error {
return s.Struct.SetText(0, v)
}
func (s JsonValue_Call) Params() (JsonValue_List, error) {
p, err := s.Struct.Ptr(1)
return JsonValue_List{List: p.List()}, err
}
func (s JsonValue_Call) HasParams() bool {
p, err := s.Struct.Ptr(1)
return p.IsValid() || err != nil
}
func (s JsonValue_Call) SetParams(v JsonValue_List) error {
return s.Struct.SetPtr(1, v.List.ToPtr())
}
// NewParams sets the params field to a newly
// allocated JsonValue_List, preferring placement in s's segment.
func (s JsonValue_Call) NewParams(n int32) (JsonValue_List, error) {
l, err := NewJsonValue_List(s.Struct.Segment(), n)
if err != nil {
return JsonValue_List{}, err
}
err = s.Struct.SetPtr(1, l.List.ToPtr())
return l, err
}
// JsonValue_Call_List is a list of JsonValue_Call.
type JsonValue_Call_List struct{ capnp.List }
// NewJsonValue_Call creates a new list of JsonValue_Call.
func NewJsonValue_Call_List(s *capnp.Segment, sz int32) (JsonValue_Call_List, error) {
l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}, sz)
return JsonValue_Call_List{l}, err
}
func (s JsonValue_Call_List) At(i int) JsonValue_Call { return JsonValue_Call{s.List.Struct(i)} }
func (s JsonValue_Call_List) Set(i int, v JsonValue_Call) error { return s.List.SetStruct(i, v.Struct) }
func (s JsonValue_Call_List) String() string {
str, _ := text.MarshalList(0x9bbf84153dd4bb60, s.List)
return str
}
// JsonValue_Call_Promise is a wrapper for a JsonValue_Call promised by a client call.
type JsonValue_Call_Promise struct{ *capnp.Pipeline }
func (p JsonValue_Call_Promise) Struct() (JsonValue_Call, error) {
s, err := p.Pipeline.Struct()
return JsonValue_Call{s}, err
}
const schema_8ef99297a43a5e34 = "x\xdat\x92AHTQ\x14\x86\xff\xff\xde7\xa3\xe2" +
"L\xf3^\xf3\xa4\x16\x89\x9b\xa2\x1235!\x18\x88)" +
"-\x09\x17\xe1m\xa8e\xf9\x1c_1r}O\xde8" +
"Y+7\x05\xb5\xa8(\x88\x16\xad\x826\xbajQ\x90" +
"\x94\x94\xd2\xb2U\xb4\x08W-\xda\x04m\xdaee7" +
"n\x92O$w\x87s\xce=\xff\xcf\xf7\xdf\x9e\x93<" +
".z33\x12P\x072Y\x93\xact\xdd\x987\xfb" +
"nB\xb5R\x98\xfe\x0b\xa5'\x0f\xef\xaf\xde\xc1)6" +
"5\x01\xc5\xc7\x9c/\xceq?pd\x91w\x09\x9a\xd1" +
"\x97\x1f\x8e\xb5]\x7f\xfd\x08^\x1b\xd3\xb7\x19a\x97o" +
"\xc9\xf7\xc5\x07\xd2V\xf7\xe4\x0ch\xde\x1d\x9d\xab|<" +
"wu\xf9\x7f\xbbtV\x8ay\xc7V-\xce\x0c\xce\x98" +
"\x89z\x1cuW\x83)FS\xa5\xe1z\x1c\x9d/\x04" +
"\xba\x11\xaafn>\xd3\xd2\xb7I?\xd3\xd91T\x0b" +
"\xf5xa0\xd0Z\xed\x91N\xce\x18\x87\x80\xf7\xbc\x13" +
"PO%\xd5+\xc1v\xfe6\xaeO\xdb^\x18\x00\xd4" +
"3I\xf5F\xb0]\xac\x19\xfa\x14\x80\xb7X\x02\xd4\x0b" +
"I\xf5V0/\x7f\x19\x9f\x12\xf0\x96J\xdeR\x87\xfa" +
"$\xa9\xbe\x0a\xe6\x9d\x9f\xc6\xa7\x03x_\xfa\x00\xf5Y" +
"\xf2,\x05\xf3\x99\x1f\xc6g\x06\xf0\xd6\xec\x89\xef\x92\x15" +
"\xdf\xb6\xb3\xab\xc6g\x16(z\xec\x04*9JVv" +
"S\xb0\x105\xb4Fvv,\x8eu\x18D$\x04\x09" +
"\x96\xa3\xc6\xe4X\x98\xb0\x15\x82\xad`\xb9>\x9d\xd4\xa2" +
"\xcb\xca\xa10\xdfn\x1f\xde\xb5sta\x19\xca\x11<" +
"\xe1\x929\xc0\xe3\xc0\xec\xfa\xcaE\x809\x08\xe6\xc0\x8e" +
" I\x82k\xdc\x01\x8eH\xd2MY\x83\xb6Y\x8e\xc7" +
"&\xc2\xeat:\xdf \xba>/T\x03\xad\xe9\xa6l" +
"A\xba\xe0F&\xe2_&6\x92\xee\xc1@S\x8f\x90" +
"\xaaY:\xc0_\xe2\x07\x87\xedg\x92T\xfd\x82\x1e\xb9" +
"\xce\xbb\xd7R\xe9\x92T\xa7\x05\xcd\xa5FT\x9d\xae\xc5" +
"\x11R\xd3\xe5\xa9 \x09&\xeb\xdb\xba\xdeF~\xa8\x16" +
"J=\xbeE\xdf&\xbeWR\xf5l\xd2?\xd4\x97\x9a" +
"*D\xc1d\xb8A\xeb\x8a=\xb4E\xd0\x05\xff\x04\x00" +
"\x00\xff\xff\x9f\xdb\xc7\x93"
func init() {
schemas.Register(schema_8ef99297a43a5e34,
0x8825ffaa852cda72,
0x9bbf84153dd4bb60,
0xc27855d853a937cc)
}

View File

@@ -0,0 +1,142 @@
# Copyright (c) 2014 Sandstorm Development Group, Inc. and contributors
# Licensed under the MIT License:
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
@0xb8630836983feed7;
$import "/capnp/c++.capnp".namespace("capnp");
interface Persistent@0xc8cb212fcd9f5691(SturdyRef, Owner) {
# Interface implemented by capabilities that outlive a single connection. A client may save()
# the capability, producing a SturdyRef. The SturdyRef can be stored to disk, then later used to
# obtain a new reference to the capability on a future connection.
#
# The exact format of SturdyRef depends on the "realm" in which the SturdyRef appears. A "realm"
# is an abstract space in which all SturdyRefs have the same format and refer to the same set of
# resources. Every vat is in exactly one realm. All capability clients within that vat must
# produce SturdyRefs of the format appropriate for the realm.
#
# Similarly, every VatNetwork also resides in a particular realm. Usually, a vat's "realm"
# corresponds to the realm of its main VatNetwork. However, a Vat can in fact communicate over
# a VatNetwork in a different realm -- in this case, all SturdyRefs need to be transformed when
# coming or going through said VatNetwork. The RPC system has hooks for registering
# transformation callbacks for this purpose.
#
# Since the format of SturdyRef is realm-dependent, it is not defined here. An application should
# choose an appropriate realm for itself as part of its design. Note that under Sandstorm, every
# application exists in its own realm and is therefore free to define its own SturdyRef format;
# the Sandstorm platform handles translating between realms.
#
# Note that whether a capability is persistent is often orthogonal to its type. In these cases,
# the capability's interface should NOT inherit `Persistent`; instead, just perform a cast at
# runtime. It's not type-safe, but trying to be type-safe in these cases will likely lead to
# tears. In cases where a particular interface only makes sense on persistent capabilities, it
# still should not explicitly inherit Persistent because the `SturdyRef` and `Owner` types will
# vary between realms (they may even be different at the call site than they are on the
# implementation). Instead, mark persistent interfaces with the $persistent annotation (defined
# below).
#
# Sealing
# -------
#
# As an added security measure, SturdyRefs may be "sealed" to a particular owner, such that
# if the SturdyRef itself leaks to a third party, that party cannot actually restore it because
# they are not the owner. To restore a sealed capability, you must first prove to its host that
# you are the rightful owner. The precise mechanism for this authentication is defined by the
# realm.
#
# Sealing is a defense-in-depth mechanism meant to mitigate damage in the case of catastrophic
# attacks. For example, say an attacker temporarily gains read access to a database full of
# SturdyRefs: it would be unfortunate if it were then necessary to revoke every single reference
# in the database to prevent the attacker from using them.
#
# In general, an "owner" is a course-grained identity. Because capability-based security is still
# the primary mechanism of security, it is not necessary nor desirable to have a separate "owner"
# identity for every single process or object; that is exactly what capabilities are supposed to
# avoid! Instead, it makes sense for an "owner" to literally identify the owner of the machines
# where the capability is stored. If untrusted third parties are able to run arbitrary code on
# said machines, then the sandbox for that code should be designed using Distributed Confinement
# such that the third-party code never sees the bits of the SturdyRefs and cannot directly
# exercise the owner's power to restore refs. See:
#
# http://www.erights.org/elib/capability/dist-confine.html
#
# Resist the urge to represent an Owner as a simple public key. The whole point of sealing is to
# defend against leaked-storage attacks. Such attacks can easily result in the owner's private
# key being stolen as well. A better solution is for `Owner` to contain a simple globally unique
# identifier for the owner, and for everyone to separately maintain a mapping of owner IDs to
# public keys. If an owner's private key is compromised, then humans will need to communicate
# and agree on a replacement public key, then update the mapping.
#
# As a concrete example, an `Owner` could simply contain a domain name, and restoring a SturdyRef
# would require signing a request using the domain's private key. Authenticating this key could
# be accomplished through certificate authorities or web-of-trust techniques.
save @0 SaveParams -> SaveResults;
# Save a capability persistently so that it can be restored by a future connection. Not all
# capabilities can be saved -- application interfaces should define which capabilities support
# this and which do not.
struct SaveParams {
sealFor @0 :Owner;
# Seal the SturdyRef so that it can only be restored by the specified Owner. This is meant
# to mitigate damage when a SturdyRef is leaked. See comments above.
#
# Leaving this value null may or may not be allowed; it is up to the realm to decide. If a
# realm does allow a null owner, this should indicate that anyone is allowed to restore the
# ref.
}
struct SaveResults {
sturdyRef @0 :SturdyRef;
}
}
interface RealmGateway(InternalRef, ExternalRef, InternalOwner, ExternalOwner) {
# Interface invoked when a SturdyRef is about to cross realms. The RPC system supports providing
# a RealmGateway as a callback hook when setting up RPC over some VatNetwork.
import @0 (cap :Persistent(ExternalRef, ExternalOwner),
params :Persistent(InternalRef, InternalOwner).SaveParams)
-> Persistent(InternalRef, InternalOwner).SaveResults;
# Given an external capability, save it and return an internal reference. Used when someone
# inside the realm tries to save a capability from outside the realm.
export @1 (cap :Persistent(InternalRef, InternalOwner),
params :Persistent(ExternalRef, ExternalOwner).SaveParams)
-> Persistent(ExternalRef, ExternalOwner).SaveResults;
# Given an internal capability, save it and return an external reference. Used when someone
# outside the realm tries to save a capability from inside the realm.
}
annotation persistent(interface, field) :Void $Go.name("PersistentAnnotation");
# Apply this annotation to interfaces for objects that will always be persistent, instead of
# extending the Persistent capability, since the correct type parameters to Persistent depend on
# the realm, which is orthogonal to the interface type and therefore should not be defined
# along-side it.
#
# You may also apply this annotation to a capability-typed field which will always contain a
# persistent capability, but where the capability's interface itself is not already marked
# persistent.
#
# Note that absence of the $persistent annotation doesn't mean a capability of that type isn't
# persistent; it just means not *all* such capabilities are persistent.
using Go = import "/go.capnp";
$Go.package("persistent");
$Go.import("zombiezen.com/go/capnproto2/std/capnp/persistent");

View File

@@ -0,0 +1,15 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["persistent.capnp.go"],
importpath = "zombiezen.com/go/capnproto2/std/capnp/persistent",
visibility = ["//visibility:public"],
deps = [
"//:go_default_library",
"//encoding/text:go_default_library",
"//schemas:go_default_library",
"//server:go_default_library",
"@org_golang_x_net//context:go_default_library",
],
)

View File

@@ -0,0 +1,620 @@
// Code generated by capnpc-go. DO NOT EDIT.
package persistent
import (
context "golang.org/x/net/context"
capnp "zombiezen.com/go/capnproto2"
text "zombiezen.com/go/capnproto2/encoding/text"
schemas "zombiezen.com/go/capnproto2/schemas"
server "zombiezen.com/go/capnproto2/server"
)
const PersistentAnnotation = uint64(0xf622595091cafb67)
type Persistent struct{ Client capnp.Client }
// Persistent_TypeID is the unique identifier for the type Persistent.
const Persistent_TypeID = 0xc8cb212fcd9f5691
func (c Persistent) Save(ctx context.Context, params func(Persistent_SaveParams) error, opts ...capnp.CallOption) Persistent_SaveResults_Promise {
if c.Client == nil {
return Persistent_SaveResults_Promise{Pipeline: capnp.NewPipeline(capnp.ErrorAnswer(capnp.ErrNullClient))}
}
call := &capnp.Call{
Ctx: ctx,
Method: capnp.Method{
InterfaceID: 0xc8cb212fcd9f5691,
MethodID: 0,
InterfaceName: "persistent.capnp:Persistent",
MethodName: "save",
},
Options: capnp.NewCallOptions(opts),
}
if params != nil {
call.ParamsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 1}
call.ParamsFunc = func(s capnp.Struct) error { return params(Persistent_SaveParams{Struct: s}) }
}
return Persistent_SaveResults_Promise{Pipeline: capnp.NewPipeline(c.Client.Call(call))}
}
type Persistent_Server interface {
Save(Persistent_save) error
}
func Persistent_ServerToClient(s Persistent_Server) Persistent {
c, _ := s.(server.Closer)
return Persistent{Client: server.New(Persistent_Methods(nil, s), c)}
}
func Persistent_Methods(methods []server.Method, s Persistent_Server) []server.Method {
if cap(methods) == 0 {
methods = make([]server.Method, 0, 1)
}
methods = append(methods, server.Method{
Method: capnp.Method{
InterfaceID: 0xc8cb212fcd9f5691,
MethodID: 0,
InterfaceName: "persistent.capnp:Persistent",
MethodName: "save",
},
Impl: func(c context.Context, opts capnp.CallOptions, p, r capnp.Struct) error {
call := Persistent_save{c, opts, Persistent_SaveParams{Struct: p}, Persistent_SaveResults{Struct: r}}
return s.Save(call)
},
ResultsSize: capnp.ObjectSize{DataSize: 0, PointerCount: 1},
})
return methods
}
// Persistent_save holds the arguments for a server call to Persistent.save.
type Persistent_save struct {
Ctx context.Context
Options capnp.CallOptions
Params Persistent_SaveParams
Results Persistent_SaveResults
}
type Persistent_SaveParams struct{ capnp.Struct }
// Persistent_SaveParams_TypeID is the unique identifier for the type Persistent_SaveParams.
const Persistent_SaveParams_TypeID = 0xf76fba59183073a5
func NewPersistent_SaveParams(s *capnp.Segment) (Persistent_SaveParams, error) {
st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1})
return Persistent_SaveParams{st}, err
}
func NewRootPersistent_SaveParams(s *capnp.Segment) (Persistent_SaveParams, error) {
st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1})
return Persistent_SaveParams{st}, err
}
func ReadRootPersistent_SaveParams(msg *capnp.Message) (Persistent_SaveParams, error) {
root, err := msg.RootPtr()
return Persistent_SaveParams{root.Struct()}, err
}
func (s Persistent_SaveParams) String() string {
str, _ := text.Marshal(0xf76fba59183073a5, s.Struct)
return str
}
func (s Persistent_SaveParams) SealFor() (capnp.Pointer, error) {
return s.Struct.Pointer(0)
}
func (s Persistent_SaveParams) HasSealFor() bool {
p, err := s.Struct.Ptr(0)
return p.IsValid() || err != nil
}
func (s Persistent_SaveParams) SealForPtr() (capnp.Ptr, error) {
return s.Struct.Ptr(0)
}
func (s Persistent_SaveParams) SetSealFor(v capnp.Pointer) error {
return s.Struct.SetPointer(0, v)
}
func (s Persistent_SaveParams) SetSealForPtr(v capnp.Ptr) error {
return s.Struct.SetPtr(0, v)
}
// Persistent_SaveParams_List is a list of Persistent_SaveParams.
type Persistent_SaveParams_List struct{ capnp.List }
// NewPersistent_SaveParams creates a new list of Persistent_SaveParams.
func NewPersistent_SaveParams_List(s *capnp.Segment, sz int32) (Persistent_SaveParams_List, error) {
l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}, sz)
return Persistent_SaveParams_List{l}, err
}
func (s Persistent_SaveParams_List) At(i int) Persistent_SaveParams {
return Persistent_SaveParams{s.List.Struct(i)}
}
func (s Persistent_SaveParams_List) Set(i int, v Persistent_SaveParams) error {
return s.List.SetStruct(i, v.Struct)
}
func (s Persistent_SaveParams_List) String() string {
str, _ := text.MarshalList(0xf76fba59183073a5, s.List)
return str
}
// Persistent_SaveParams_Promise is a wrapper for a Persistent_SaveParams promised by a client call.
type Persistent_SaveParams_Promise struct{ *capnp.Pipeline }
func (p Persistent_SaveParams_Promise) Struct() (Persistent_SaveParams, error) {
s, err := p.Pipeline.Struct()
return Persistent_SaveParams{s}, err
}
func (p Persistent_SaveParams_Promise) SealFor() *capnp.Pipeline {
return p.Pipeline.GetPipeline(0)
}
type Persistent_SaveResults struct{ capnp.Struct }
// Persistent_SaveResults_TypeID is the unique identifier for the type Persistent_SaveResults.
const Persistent_SaveResults_TypeID = 0xb76848c18c40efbf
func NewPersistent_SaveResults(s *capnp.Segment) (Persistent_SaveResults, error) {
st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1})
return Persistent_SaveResults{st}, err
}
func NewRootPersistent_SaveResults(s *capnp.Segment) (Persistent_SaveResults, error) {
st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1})
return Persistent_SaveResults{st}, err
}
func ReadRootPersistent_SaveResults(msg *capnp.Message) (Persistent_SaveResults, error) {
root, err := msg.RootPtr()
return Persistent_SaveResults{root.Struct()}, err
}
func (s Persistent_SaveResults) String() string {
str, _ := text.Marshal(0xb76848c18c40efbf, s.Struct)
return str
}
func (s Persistent_SaveResults) SturdyRef() (capnp.Pointer, error) {
return s.Struct.Pointer(0)
}
func (s Persistent_SaveResults) HasSturdyRef() bool {
p, err := s.Struct.Ptr(0)
return p.IsValid() || err != nil
}
func (s Persistent_SaveResults) SturdyRefPtr() (capnp.Ptr, error) {
return s.Struct.Ptr(0)
}
func (s Persistent_SaveResults) SetSturdyRef(v capnp.Pointer) error {
return s.Struct.SetPointer(0, v)
}
func (s Persistent_SaveResults) SetSturdyRefPtr(v capnp.Ptr) error {
return s.Struct.SetPtr(0, v)
}
// Persistent_SaveResults_List is a list of Persistent_SaveResults.
type Persistent_SaveResults_List struct{ capnp.List }
// NewPersistent_SaveResults creates a new list of Persistent_SaveResults.
func NewPersistent_SaveResults_List(s *capnp.Segment, sz int32) (Persistent_SaveResults_List, error) {
l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}, sz)
return Persistent_SaveResults_List{l}, err
}
func (s Persistent_SaveResults_List) At(i int) Persistent_SaveResults {
return Persistent_SaveResults{s.List.Struct(i)}
}
func (s Persistent_SaveResults_List) Set(i int, v Persistent_SaveResults) error {
return s.List.SetStruct(i, v.Struct)
}
func (s Persistent_SaveResults_List) String() string {
str, _ := text.MarshalList(0xb76848c18c40efbf, s.List)
return str
}
// Persistent_SaveResults_Promise is a wrapper for a Persistent_SaveResults promised by a client call.
type Persistent_SaveResults_Promise struct{ *capnp.Pipeline }
func (p Persistent_SaveResults_Promise) Struct() (Persistent_SaveResults, error) {
s, err := p.Pipeline.Struct()
return Persistent_SaveResults{s}, err
}
func (p Persistent_SaveResults_Promise) SturdyRef() *capnp.Pipeline {
return p.Pipeline.GetPipeline(0)
}
type RealmGateway struct{ Client capnp.Client }
// RealmGateway_TypeID is the unique identifier for the type RealmGateway.
const RealmGateway_TypeID = 0x84ff286cd00a3ed4
func (c RealmGateway) Import(ctx context.Context, params func(RealmGateway_import_Params) error, opts ...capnp.CallOption) Persistent_SaveResults_Promise {
if c.Client == nil {
return Persistent_SaveResults_Promise{Pipeline: capnp.NewPipeline(capnp.ErrorAnswer(capnp.ErrNullClient))}
}
call := &capnp.Call{
Ctx: ctx,
Method: capnp.Method{
InterfaceID: 0x84ff286cd00a3ed4,
MethodID: 0,
InterfaceName: "persistent.capnp:RealmGateway",
MethodName: "import",
},
Options: capnp.NewCallOptions(opts),
}
if params != nil {
call.ParamsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 2}
call.ParamsFunc = func(s capnp.Struct) error { return params(RealmGateway_import_Params{Struct: s}) }
}
return Persistent_SaveResults_Promise{Pipeline: capnp.NewPipeline(c.Client.Call(call))}
}
func (c RealmGateway) Export(ctx context.Context, params func(RealmGateway_export_Params) error, opts ...capnp.CallOption) Persistent_SaveResults_Promise {
if c.Client == nil {
return Persistent_SaveResults_Promise{Pipeline: capnp.NewPipeline(capnp.ErrorAnswer(capnp.ErrNullClient))}
}
call := &capnp.Call{
Ctx: ctx,
Method: capnp.Method{
InterfaceID: 0x84ff286cd00a3ed4,
MethodID: 1,
InterfaceName: "persistent.capnp:RealmGateway",
MethodName: "export",
},
Options: capnp.NewCallOptions(opts),
}
if params != nil {
call.ParamsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 2}
call.ParamsFunc = func(s capnp.Struct) error { return params(RealmGateway_export_Params{Struct: s}) }
}
return Persistent_SaveResults_Promise{Pipeline: capnp.NewPipeline(c.Client.Call(call))}
}
type RealmGateway_Server interface {
Import(RealmGateway_import) error
Export(RealmGateway_export) error
}
func RealmGateway_ServerToClient(s RealmGateway_Server) RealmGateway {
c, _ := s.(server.Closer)
return RealmGateway{Client: server.New(RealmGateway_Methods(nil, s), c)}
}
func RealmGateway_Methods(methods []server.Method, s RealmGateway_Server) []server.Method {
if cap(methods) == 0 {
methods = make([]server.Method, 0, 2)
}
methods = append(methods, server.Method{
Method: capnp.Method{
InterfaceID: 0x84ff286cd00a3ed4,
MethodID: 0,
InterfaceName: "persistent.capnp:RealmGateway",
MethodName: "import",
},
Impl: func(c context.Context, opts capnp.CallOptions, p, r capnp.Struct) error {
call := RealmGateway_import{c, opts, RealmGateway_import_Params{Struct: p}, Persistent_SaveResults{Struct: r}}
return s.Import(call)
},
ResultsSize: capnp.ObjectSize{DataSize: 0, PointerCount: 1},
})
methods = append(methods, server.Method{
Method: capnp.Method{
InterfaceID: 0x84ff286cd00a3ed4,
MethodID: 1,
InterfaceName: "persistent.capnp:RealmGateway",
MethodName: "export",
},
Impl: func(c context.Context, opts capnp.CallOptions, p, r capnp.Struct) error {
call := RealmGateway_export{c, opts, RealmGateway_export_Params{Struct: p}, Persistent_SaveResults{Struct: r}}
return s.Export(call)
},
ResultsSize: capnp.ObjectSize{DataSize: 0, PointerCount: 1},
})
return methods
}
// RealmGateway_import holds the arguments for a server call to RealmGateway.import.
type RealmGateway_import struct {
Ctx context.Context
Options capnp.CallOptions
Params RealmGateway_import_Params
Results Persistent_SaveResults
}
// RealmGateway_export holds the arguments for a server call to RealmGateway.export.
type RealmGateway_export struct {
Ctx context.Context
Options capnp.CallOptions
Params RealmGateway_export_Params
Results Persistent_SaveResults
}
type RealmGateway_import_Params struct{ capnp.Struct }
// RealmGateway_import_Params_TypeID is the unique identifier for the type RealmGateway_import_Params.
const RealmGateway_import_Params_TypeID = 0xf0c2cc1d3909574d
func NewRealmGateway_import_Params(s *capnp.Segment) (RealmGateway_import_Params, error) {
st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2})
return RealmGateway_import_Params{st}, err
}
func NewRootRealmGateway_import_Params(s *capnp.Segment) (RealmGateway_import_Params, error) {
st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2})
return RealmGateway_import_Params{st}, err
}
func ReadRootRealmGateway_import_Params(msg *capnp.Message) (RealmGateway_import_Params, error) {
root, err := msg.RootPtr()
return RealmGateway_import_Params{root.Struct()}, err
}
func (s RealmGateway_import_Params) String() string {
str, _ := text.Marshal(0xf0c2cc1d3909574d, s.Struct)
return str
}
func (s RealmGateway_import_Params) Cap() Persistent {
p, _ := s.Struct.Ptr(0)
return Persistent{Client: p.Interface().Client()}
}
func (s RealmGateway_import_Params) HasCap() bool {
p, err := s.Struct.Ptr(0)
return p.IsValid() || err != nil
}
func (s RealmGateway_import_Params) SetCap(v Persistent) error {
if v.Client == nil {
return s.Struct.SetPtr(0, capnp.Ptr{})
}
seg := s.Segment()
in := capnp.NewInterface(seg, seg.Message().AddCap(v.Client))
return s.Struct.SetPtr(0, in.ToPtr())
}
func (s RealmGateway_import_Params) Params() (Persistent_SaveParams, error) {
p, err := s.Struct.Ptr(1)
return Persistent_SaveParams{Struct: p.Struct()}, err
}
func (s RealmGateway_import_Params) HasParams() bool {
p, err := s.Struct.Ptr(1)
return p.IsValid() || err != nil
}
func (s RealmGateway_import_Params) SetParams(v Persistent_SaveParams) error {
return s.Struct.SetPtr(1, v.Struct.ToPtr())
}
// NewParams sets the params field to a newly
// allocated Persistent_SaveParams struct, preferring placement in s's segment.
func (s RealmGateway_import_Params) NewParams() (Persistent_SaveParams, error) {
ss, err := NewPersistent_SaveParams(s.Struct.Segment())
if err != nil {
return Persistent_SaveParams{}, err
}
err = s.Struct.SetPtr(1, ss.Struct.ToPtr())
return ss, err
}
// RealmGateway_import_Params_List is a list of RealmGateway_import_Params.
type RealmGateway_import_Params_List struct{ capnp.List }
// NewRealmGateway_import_Params creates a new list of RealmGateway_import_Params.
func NewRealmGateway_import_Params_List(s *capnp.Segment, sz int32) (RealmGateway_import_Params_List, error) {
l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}, sz)
return RealmGateway_import_Params_List{l}, err
}
func (s RealmGateway_import_Params_List) At(i int) RealmGateway_import_Params {
return RealmGateway_import_Params{s.List.Struct(i)}
}
func (s RealmGateway_import_Params_List) Set(i int, v RealmGateway_import_Params) error {
return s.List.SetStruct(i, v.Struct)
}
func (s RealmGateway_import_Params_List) String() string {
str, _ := text.MarshalList(0xf0c2cc1d3909574d, s.List)
return str
}
// RealmGateway_import_Params_Promise is a wrapper for a RealmGateway_import_Params promised by a client call.
type RealmGateway_import_Params_Promise struct{ *capnp.Pipeline }
func (p RealmGateway_import_Params_Promise) Struct() (RealmGateway_import_Params, error) {
s, err := p.Pipeline.Struct()
return RealmGateway_import_Params{s}, err
}
func (p RealmGateway_import_Params_Promise) Cap() Persistent {
return Persistent{Client: p.Pipeline.GetPipeline(0).Client()}
}
func (p RealmGateway_import_Params_Promise) Params() Persistent_SaveParams_Promise {
return Persistent_SaveParams_Promise{Pipeline: p.Pipeline.GetPipeline(1)}
}
type RealmGateway_export_Params struct{ capnp.Struct }
// RealmGateway_export_Params_TypeID is the unique identifier for the type RealmGateway_export_Params.
const RealmGateway_export_Params_TypeID = 0xecafa18b482da3aa
func NewRealmGateway_export_Params(s *capnp.Segment) (RealmGateway_export_Params, error) {
st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2})
return RealmGateway_export_Params{st}, err
}
func NewRootRealmGateway_export_Params(s *capnp.Segment) (RealmGateway_export_Params, error) {
st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2})
return RealmGateway_export_Params{st}, err
}
func ReadRootRealmGateway_export_Params(msg *capnp.Message) (RealmGateway_export_Params, error) {
root, err := msg.RootPtr()
return RealmGateway_export_Params{root.Struct()}, err
}
func (s RealmGateway_export_Params) String() string {
str, _ := text.Marshal(0xecafa18b482da3aa, s.Struct)
return str
}
func (s RealmGateway_export_Params) Cap() Persistent {
p, _ := s.Struct.Ptr(0)
return Persistent{Client: p.Interface().Client()}
}
func (s RealmGateway_export_Params) HasCap() bool {
p, err := s.Struct.Ptr(0)
return p.IsValid() || err != nil
}
func (s RealmGateway_export_Params) SetCap(v Persistent) error {
if v.Client == nil {
return s.Struct.SetPtr(0, capnp.Ptr{})
}
seg := s.Segment()
in := capnp.NewInterface(seg, seg.Message().AddCap(v.Client))
return s.Struct.SetPtr(0, in.ToPtr())
}
func (s RealmGateway_export_Params) Params() (Persistent_SaveParams, error) {
p, err := s.Struct.Ptr(1)
return Persistent_SaveParams{Struct: p.Struct()}, err
}
func (s RealmGateway_export_Params) HasParams() bool {
p, err := s.Struct.Ptr(1)
return p.IsValid() || err != nil
}
func (s RealmGateway_export_Params) SetParams(v Persistent_SaveParams) error {
return s.Struct.SetPtr(1, v.Struct.ToPtr())
}
// NewParams sets the params field to a newly
// allocated Persistent_SaveParams struct, preferring placement in s's segment.
func (s RealmGateway_export_Params) NewParams() (Persistent_SaveParams, error) {
ss, err := NewPersistent_SaveParams(s.Struct.Segment())
if err != nil {
return Persistent_SaveParams{}, err
}
err = s.Struct.SetPtr(1, ss.Struct.ToPtr())
return ss, err
}
// RealmGateway_export_Params_List is a list of RealmGateway_export_Params.
type RealmGateway_export_Params_List struct{ capnp.List }
// NewRealmGateway_export_Params creates a new list of RealmGateway_export_Params.
func NewRealmGateway_export_Params_List(s *capnp.Segment, sz int32) (RealmGateway_export_Params_List, error) {
l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}, sz)
return RealmGateway_export_Params_List{l}, err
}
func (s RealmGateway_export_Params_List) At(i int) RealmGateway_export_Params {
return RealmGateway_export_Params{s.List.Struct(i)}
}
func (s RealmGateway_export_Params_List) Set(i int, v RealmGateway_export_Params) error {
return s.List.SetStruct(i, v.Struct)
}
func (s RealmGateway_export_Params_List) String() string {
str, _ := text.MarshalList(0xecafa18b482da3aa, s.List)
return str
}
// RealmGateway_export_Params_Promise is a wrapper for a RealmGateway_export_Params promised by a client call.
type RealmGateway_export_Params_Promise struct{ *capnp.Pipeline }
func (p RealmGateway_export_Params_Promise) Struct() (RealmGateway_export_Params, error) {
s, err := p.Pipeline.Struct()
return RealmGateway_export_Params{s}, err
}
func (p RealmGateway_export_Params_Promise) Cap() Persistent {
return Persistent{Client: p.Pipeline.GetPipeline(0).Client()}
}
func (p RealmGateway_export_Params_Promise) Params() Persistent_SaveParams_Promise {
return Persistent_SaveParams_Promise{Pipeline: p.Pipeline.GetPipeline(1)}
}
const schema_b8630836983feed7 = "x\xda\xbcSKh3U\x14>\xdf\xdcy$\xd2\x9f" +
"?7\xf3\x97Vh\x8d--\xb5b_\x0ab\x8b\x98" +
"L\xa1\xb6]\xa8\x99\x14\x94\x0a\x827u\xaa\x85d2" +
"\xccL_\x0bQA\x10\xd1.\xbas'\"n\x0a\xe2" +
"R\xebF,\x0a\xe2\x03\x14\x94\xee\xbb\x16\xad.t\xe1" +
"\xe2\xca\x9d\xbc\xc66\xa5H\xc5\xcd\xc0\x9c{\xee\xfd\xce" +
"\xf9\x1e\xb3\xe7(is\xc6\xa9N\xe4>b\x98\xf2\xc7" +
"\xc7\xee\xfa\xbev\x9f|\x9d8g\xf2\xf4\x97\xe2;\x0f" +
"g6>!\xa2\x1clW\xfb\xdd~N\xb3\x88\xecu" +
"\xed\x0d[0\xcb\x16lB~\xf6k\xe9\xed\xcfW^" +
"\xfa\x98\xf8\x10\xe4\xe1\xd3\xef~73\xf2\xcdWd\xc0" +
"\xca\xe1\xa1\x97\xd9\"\xec\x03\xa6\xae\xbc\xc9\x8a\x94:\xbf" +
"\xfc\xfa\x87\xec\xcc>f\x13D\xf6Ol\xd9\x1e\xd7-" +
"{\\\x1f\x90G\xefO\xad\xbc\xf5\xdeG?\x13\xbf\x07" +
"D\x86\xa6^\x1d\xd7\xab \xd8s\xfa.A>\xf1L" +
"v~\xf8\xdb\x93\xf3t\xc3\xb0\x914L\x1a\xaa\xe1\xc5" +
"\xbf\xbe>,\xaf\x8f\xfeA?p\xe3^\xa4@a\xf7" +
"\x9bg\xf6\x88i\xd9#fam\xc5d \xc8\x0f\xa2" +
"\xd9\xc1\xf5O\x1b\x7f\xf6\xdaf\xde\\\x80\xbdj\xaam" +
"\x96\xcc\"=)\x03/\x8c\xb6\xa2\xd8\xd3\xfcxzC" +
"\x04~\xb0P\xf1D\xad\xbe,\x0a\xb1\xb7+\xf6\xcb\x80" +
"\x9ba\x06QgH\xb4\xc9\xe2s\x0bD\xce\x03p\x1e" +
"\x05\x7f\xcd\x02:{v;\xb6UG\x00\xe7U\xf0/" +
"\xad\xe2V=h\x841G\xc1\xd55tE\x02\x88\xda" +
"\xc5\xce\xb4\xaa4\xe1f\x80\x04_}s\x0c\xc8#u" +
"\x8f\x08y\x03Z\xbaPB\xd1\xdb\xbb1\x88q\x19\x85" +
"\xfd\x13\xa5\x0c89\xf0[U\xce\xab\xbc?\xe4w\x87" +
"r\xd5\x8f\xbd\xd0\x175\xb2*\xde\xa6\\\xdaK\xffu" +
"\xce\x0aO\xed\xfa^\xd8=m\xfd\xb75\xd0;\x1a\x94" +
"[\x15?\x9e^\x13;^\xc5\x8b\xb6kqDJ\x0d" +
"\x9d\xe9D\xbaZ\xe7V\x85\xc8\xedcp\x075\xc8(" +
"\xde\x0e_\xd8\xafx\x84\xcd\x84\xa6\xd4\x92\xc8\x13z\xe8" +
"\xdc\xc2\xb0<?V\x1c\xa4l\x93}6\x95\x88lU" +
"\xaa\x11\xca\"\x14\xc4\xea\x91l\xcfCV-\x8e\\=" +
"\xf1F\xfbjWy~?\x91\xd3\x07g\x08|\xca\xba" +
"\x1d\x89\x1d\xef\x12\xfb=%Q\xc5&\xbf\x19p\xa3\xc2" +
"\xb3\x0f\xca\xb5\xeefW\xf2\xd5\xf2lb\xd9\xe9\xa6\x05" +
"\xc6\xca\"\xb4D=r3\x1d\xc2&G\x89\xdc1\x06" +
"wO\x03\x07\xee$\x13(\x8f\xba\x01\x83\xfb\x85\x06k" +
"C\x04\xe0i\xeeJ\xf8\x8f\xac\x09N(\x06\"\x14\xf5" +
"\x08\xb9.\xd7\xff\x06\xe1:_\"\x97\xd2\xf9\x0an\x9a" +
"\x19\xfc\xbf\xb9\xb9v\xf2\x9b\x93s\x1d\xfd\xb9\x9e\x19\x08" +
"\xba\x19H\xb2\x05M\xfev03\x90\x7f\xfe\xf8\x84\x14" +
"\xac3\x08\xf4)\xc4#\xd9\x8e$\xfc\xd8\xf1\xfdF," +
"n\xc7[\x0d\x9f\xf4\xce\xab\xec\xaa\xf4\x16\xcb\xc9f\x17" +
"\xc2\xbbH\xa4\xe6w\xefhx%\xf2D\xed\xf1F\xd8" +
"$\xeaBr\xff\x0e\x00\x00\xff\xff\x1ar\xf0\xc2"
func init() {
schemas.Register(schema_b8630836983feed7,
0x84ff286cd00a3ed4,
0xb76848c18c40efbf,
0xc8cb212fcd9f5691,
0xecafa18b482da3aa,
0xf0c2cc1d3909574d,
0xf622595091cafb67,
0xf76fba59183073a5)
}

View File

@@ -0,0 +1,172 @@
# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
# Licensed under the MIT License:
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
@0xa184c7885cdaf2a1;
# This file defines the "network-specific parameters" in rpc.capnp to support a network consisting
# of two vats. Each of these vats may in fact be in communication with other vats, but any
# capabilities they forward must be proxied. Thus, to each end of the connection, all capabilities
# received from the other end appear to live in a single vat.
#
# Two notable use cases for this model include:
# - Regular client-server communications, where a remote client machine (perhaps living on an end
# user's personal device) connects to a server. The server may be part of a cluster, and may
# call on other servers in the cluster to help service the user's request. It may even obtain
# capabilities from these other servers which it passes on to the user. To simplify network
# common traversal problems (e.g. if the user is behind a firewall), it is probably desirable to
# multiplex all communications between the server cluster and the client over the original
# connection rather than form new ones. This connection should use the two-party protocol, as
# the client has no interest in knowing about additional servers.
# - Applications running in a sandbox. A supervisor process may execute a confined application
# such that all of the confined app's communications with the outside world must pass through
# the supervisor. In this case, the connection between the confined app and the supervisor might
# as well use the two-party protocol, because the confined app is intentionally prevented from
# talking to any other vat anyway. Any external resources will be proxied through the supervisor,
# and so to the contained app will appear as if they were hosted by the supervisor itself.
#
# Since there are only two vats in this network, there is never a need for three-way introductions,
# so level 3 is free. Moreover, because it is never necessary to form new connections, the
# two-party protocol can be used easily anywhere where a two-way byte stream exists, without regard
# to where that byte stream goes or how it was initiated. This makes the two-party runtime library
# highly reusable.
#
# Joins (level 4) _could_ be needed in cases where one or both vats are participating in other
# networks that use joins. For instance, if Alice and Bob are speaking through the two-party
# protocol, and Bob is also participating on another network, Bob may send Alice two or more
# proxied capabilities which, unbeknownst to Bob at the time, are in fact pointing at the same
# remote object. Alice may then request to join these capabilities, at which point Bob will have
# to forward the join to the other network. Note, however, that if Alice is _not_ participating on
# any other network, then Alice will never need to _receive_ a Join, because Alice would always
# know when two locally-hosted capabilities are the same and would never export a redundant alias
# to Bob. So, Alice can respond to all incoming joins with an error, and only needs to implement
# outgoing joins if she herself desires to use this feature. Also, outgoing joins are relatively
# easy to implement in this scenario.
#
# What all this means is that a level 4 implementation of the confined network is barely more
# complicated than a level 2 implementation. However, such an implementation allows the "client"
# or "confined" app to access the server's/supervisor's network with equal functionality to any
# native participant. In other words, an application which implements only the two-party protocol
# can be paired with a proxy app in order to participate in any network.
#
# So, when implementing Cap'n Proto in a new language, it makes sense to implement only the
# two-party protocol initially, and then pair applications with an appropriate proxy written in
# C++, rather than implement other parameterizations of the RPC protocol directly.
using Cxx = import "/capnp/c++.capnp";
$Cxx.namespace("capnp::rpc::twoparty");
# Note: SturdyRef is not specified here. It is up to the application to define semantics of
# SturdyRefs if desired.
enum Side {
server @0;
# The object lives on the "server" or "supervisor" end of the connection. Only the
# server/supervisor knows how to interpret the ref; to the client, it is opaque.
#
# Note that containers intending to implement strong confinement should rewrite SturdyRefs
# received from the external network before passing them on to the confined app. The confined
# app thus does not ever receive the raw bits of the SturdyRef (which it could perhaps
# maliciously leak), but instead receives only a thing that it can pass back to the container
# later to restore the ref. See:
# http://www.erights.org/elib/capability/dist-confine.html
client @1;
# The object lives on the "client" or "confined app" end of the connection. Only the client
# knows how to interpret the ref; to the server/supervisor, it is opaque. Most clients do not
# actually know how to persist capabilities at all, so use of this is unusual.
}
struct VatId {
side @0 :Side;
}
struct ProvisionId {
# Only used for joins, since three-way introductions never happen on a two-party network.
joinId @0 :UInt32;
# The ID from `JoinKeyPart`.
}
struct RecipientId {}
# Never used, because there are only two parties.
struct ThirdPartyCapId {}
# Never used, because there is no third party.
struct JoinKeyPart {
# Joins in the two-party case are simplified by a few observations.
#
# First, on a two-party network, a Join only ever makes sense if the receiving end is also
# connected to other networks. A vat which is not connected to any other network can safely
# reject all joins.
#
# Second, since a two-party connection bisects the network -- there can be no other connections
# between the networks at either end of the connection -- if one part of a join crosses the
# connection, then _all_ parts must cross it. Therefore, a vat which is receiving a Join request
# off some other network which needs to be forwarded across the two-party connection can
# collect all the parts on its end and only forward them across the two-party connection when all
# have been received.
#
# For example, imagine that Alice and Bob are vats connected over a two-party connection, and
# each is also connected to other networks. At some point, Alice receives one part of a Join
# request off her network. The request is addressed to a capability that Alice received from
# Bob and is proxying to her other network. Alice goes ahead and responds to the Join part as
# if she hosted the capability locally (this is important so that if not all the Join parts end
# up at Alice, the original sender can detect the failed Join without hanging). As other parts
# trickle in, Alice verifies that each part is addressed to a capability from Bob and continues
# to respond to each one. Once the complete set of join parts is received, Alice checks if they
# were all for the exact same capability. If so, she doesn't need to send anything to Bob at
# all. Otherwise, she collects the set of capabilities (from Bob) to which the join parts were
# addressed and essentially initiates a _new_ Join request on those capabilities to Bob. Alice
# does not forward the Join parts she received herself, but essentially forwards the Join as a
# whole.
#
# On Bob's end, since he knows that Alice will always send all parts of a Join together, he
# simply waits until he's received them all, then performs a join on the respective capabilities
# as if it had been requested locally.
joinId @0 :UInt32;
# A number identifying this join, chosen by the sender. May be reused once `Finish` messages are
# sent corresponding to all of the `Join` messages.
partCount @1 :UInt16;
# The number of capabilities to be joined.
partNum @2 :UInt16;
# Which part this request targets -- a number in the range [0, partCount).
}
struct JoinResult {
joinId @0 :UInt32;
# Matches `JoinKeyPart`.
succeeded @1 :Bool;
# All JoinResults in the set will have the same value for `succeeded`. The receiver actually
# implements the join by waiting for all the `JoinKeyParts` and then performing its own join on
# them, then going back and answering all the join requests afterwards.
cap @2 :AnyPointer;
# One of the JoinResults will have a non-null `cap` which is the joined capability.
#
# TODO(cleanup): Change `AnyPointer` to `Capability` when that is supported.
}
using Go = import "/go.capnp";
$Go.package("rpctwoparty");
$Go.import("zombiezen.com/go/capnproto2/std/capnp/rpctwoparty");

1402
vendor/zombiezen.com/go/capnproto2/std/capnp/rpc.capnp generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["rpc.capnp.go"],
importpath = "zombiezen.com/go/capnproto2/std/capnp/rpc",
visibility = ["//visibility:public"],
deps = [
"//:go_default_library",
"//encoding/text:go_default_library",
"//schemas:go_default_library",
],
)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["rpc-twoparty.capnp.go"],
importpath = "zombiezen.com/go/capnproto2/std/capnp/rpctwoparty",
visibility = ["//visibility:public"],
deps = [
"//:go_default_library",
"//encoding/text:go_default_library",
"//schemas:go_default_library",
],
)

View File

@@ -0,0 +1,498 @@
// Code generated by capnpc-go. DO NOT EDIT.
package rpctwoparty
import (
capnp "zombiezen.com/go/capnproto2"
text "zombiezen.com/go/capnproto2/encoding/text"
schemas "zombiezen.com/go/capnproto2/schemas"
)
type Side uint16
// Side_TypeID is the unique identifier for the type Side.
const Side_TypeID = 0x9fd69ebc87b9719c
// Values of Side.
const (
Side_server Side = 0
Side_client Side = 1
)
// String returns the enum's constant name.
func (c Side) String() string {
switch c {
case Side_server:
return "server"
case Side_client:
return "client"
default:
return ""
}
}
// SideFromString returns the enum value with a name,
// or the zero value if there's no such value.
func SideFromString(c string) Side {
switch c {
case "server":
return Side_server
case "client":
return Side_client
default:
return 0
}
}
type Side_List struct{ capnp.List }
func NewSide_List(s *capnp.Segment, sz int32) (Side_List, error) {
l, err := capnp.NewUInt16List(s, sz)
return Side_List{l.List}, err
}
func (l Side_List) At(i int) Side {
ul := capnp.UInt16List{List: l.List}
return Side(ul.At(i))
}
func (l Side_List) Set(i int, v Side) {
ul := capnp.UInt16List{List: l.List}
ul.Set(i, uint16(v))
}
type VatId struct{ capnp.Struct }
// VatId_TypeID is the unique identifier for the type VatId.
const VatId_TypeID = 0xd20b909fee733a8e
func NewVatId(s *capnp.Segment) (VatId, error) {
st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0})
return VatId{st}, err
}
func NewRootVatId(s *capnp.Segment) (VatId, error) {
st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0})
return VatId{st}, err
}
func ReadRootVatId(msg *capnp.Message) (VatId, error) {
root, err := msg.RootPtr()
return VatId{root.Struct()}, err
}
func (s VatId) String() string {
str, _ := text.Marshal(0xd20b909fee733a8e, s.Struct)
return str
}
func (s VatId) Side() Side {
return Side(s.Struct.Uint16(0))
}
func (s VatId) SetSide(v Side) {
s.Struct.SetUint16(0, uint16(v))
}
// VatId_List is a list of VatId.
type VatId_List struct{ capnp.List }
// NewVatId creates a new list of VatId.
func NewVatId_List(s *capnp.Segment, sz int32) (VatId_List, error) {
l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0}, sz)
return VatId_List{l}, err
}
func (s VatId_List) At(i int) VatId { return VatId{s.List.Struct(i)} }
func (s VatId_List) Set(i int, v VatId) error { return s.List.SetStruct(i, v.Struct) }
func (s VatId_List) String() string {
str, _ := text.MarshalList(0xd20b909fee733a8e, s.List)
return str
}
// VatId_Promise is a wrapper for a VatId promised by a client call.
type VatId_Promise struct{ *capnp.Pipeline }
func (p VatId_Promise) Struct() (VatId, error) {
s, err := p.Pipeline.Struct()
return VatId{s}, err
}
type ProvisionId struct{ capnp.Struct }
// ProvisionId_TypeID is the unique identifier for the type ProvisionId.
const ProvisionId_TypeID = 0xb88d09a9c5f39817
func NewProvisionId(s *capnp.Segment) (ProvisionId, error) {
st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0})
return ProvisionId{st}, err
}
func NewRootProvisionId(s *capnp.Segment) (ProvisionId, error) {
st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0})
return ProvisionId{st}, err
}
func ReadRootProvisionId(msg *capnp.Message) (ProvisionId, error) {
root, err := msg.RootPtr()
return ProvisionId{root.Struct()}, err
}
func (s ProvisionId) String() string {
str, _ := text.Marshal(0xb88d09a9c5f39817, s.Struct)
return str
}
func (s ProvisionId) JoinId() uint32 {
return s.Struct.Uint32(0)
}
func (s ProvisionId) SetJoinId(v uint32) {
s.Struct.SetUint32(0, v)
}
// ProvisionId_List is a list of ProvisionId.
type ProvisionId_List struct{ capnp.List }
// NewProvisionId creates a new list of ProvisionId.
func NewProvisionId_List(s *capnp.Segment, sz int32) (ProvisionId_List, error) {
l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0}, sz)
return ProvisionId_List{l}, err
}
func (s ProvisionId_List) At(i int) ProvisionId { return ProvisionId{s.List.Struct(i)} }
func (s ProvisionId_List) Set(i int, v ProvisionId) error { return s.List.SetStruct(i, v.Struct) }
func (s ProvisionId_List) String() string {
str, _ := text.MarshalList(0xb88d09a9c5f39817, s.List)
return str
}
// ProvisionId_Promise is a wrapper for a ProvisionId promised by a client call.
type ProvisionId_Promise struct{ *capnp.Pipeline }
func (p ProvisionId_Promise) Struct() (ProvisionId, error) {
s, err := p.Pipeline.Struct()
return ProvisionId{s}, err
}
type RecipientId struct{ capnp.Struct }
// RecipientId_TypeID is the unique identifier for the type RecipientId.
const RecipientId_TypeID = 0x89f389b6fd4082c1
func NewRecipientId(s *capnp.Segment) (RecipientId, error) {
st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0})
return RecipientId{st}, err
}
func NewRootRecipientId(s *capnp.Segment) (RecipientId, error) {
st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0})
return RecipientId{st}, err
}
func ReadRootRecipientId(msg *capnp.Message) (RecipientId, error) {
root, err := msg.RootPtr()
return RecipientId{root.Struct()}, err
}
func (s RecipientId) String() string {
str, _ := text.Marshal(0x89f389b6fd4082c1, s.Struct)
return str
}
// RecipientId_List is a list of RecipientId.
type RecipientId_List struct{ capnp.List }
// NewRecipientId creates a new list of RecipientId.
func NewRecipientId_List(s *capnp.Segment, sz int32) (RecipientId_List, error) {
l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz)
return RecipientId_List{l}, err
}
func (s RecipientId_List) At(i int) RecipientId { return RecipientId{s.List.Struct(i)} }
func (s RecipientId_List) Set(i int, v RecipientId) error { return s.List.SetStruct(i, v.Struct) }
func (s RecipientId_List) String() string {
str, _ := text.MarshalList(0x89f389b6fd4082c1, s.List)
return str
}
// RecipientId_Promise is a wrapper for a RecipientId promised by a client call.
type RecipientId_Promise struct{ *capnp.Pipeline }
func (p RecipientId_Promise) Struct() (RecipientId, error) {
s, err := p.Pipeline.Struct()
return RecipientId{s}, err
}
type ThirdPartyCapId struct{ capnp.Struct }
// ThirdPartyCapId_TypeID is the unique identifier for the type ThirdPartyCapId.
const ThirdPartyCapId_TypeID = 0xb47f4979672cb59d
func NewThirdPartyCapId(s *capnp.Segment) (ThirdPartyCapId, error) {
st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0})
return ThirdPartyCapId{st}, err
}
func NewRootThirdPartyCapId(s *capnp.Segment) (ThirdPartyCapId, error) {
st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0})
return ThirdPartyCapId{st}, err
}
func ReadRootThirdPartyCapId(msg *capnp.Message) (ThirdPartyCapId, error) {
root, err := msg.RootPtr()
return ThirdPartyCapId{root.Struct()}, err
}
func (s ThirdPartyCapId) String() string {
str, _ := text.Marshal(0xb47f4979672cb59d, s.Struct)
return str
}
// ThirdPartyCapId_List is a list of ThirdPartyCapId.
type ThirdPartyCapId_List struct{ capnp.List }
// NewThirdPartyCapId creates a new list of ThirdPartyCapId.
func NewThirdPartyCapId_List(s *capnp.Segment, sz int32) (ThirdPartyCapId_List, error) {
l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz)
return ThirdPartyCapId_List{l}, err
}
func (s ThirdPartyCapId_List) At(i int) ThirdPartyCapId { return ThirdPartyCapId{s.List.Struct(i)} }
func (s ThirdPartyCapId_List) Set(i int, v ThirdPartyCapId) error {
return s.List.SetStruct(i, v.Struct)
}
func (s ThirdPartyCapId_List) String() string {
str, _ := text.MarshalList(0xb47f4979672cb59d, s.List)
return str
}
// ThirdPartyCapId_Promise is a wrapper for a ThirdPartyCapId promised by a client call.
type ThirdPartyCapId_Promise struct{ *capnp.Pipeline }
func (p ThirdPartyCapId_Promise) Struct() (ThirdPartyCapId, error) {
s, err := p.Pipeline.Struct()
return ThirdPartyCapId{s}, err
}
type JoinKeyPart struct{ capnp.Struct }
// JoinKeyPart_TypeID is the unique identifier for the type JoinKeyPart.
const JoinKeyPart_TypeID = 0x95b29059097fca83
func NewJoinKeyPart(s *capnp.Segment) (JoinKeyPart, error) {
st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0})
return JoinKeyPart{st}, err
}
func NewRootJoinKeyPart(s *capnp.Segment) (JoinKeyPart, error) {
st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0})
return JoinKeyPart{st}, err
}
func ReadRootJoinKeyPart(msg *capnp.Message) (JoinKeyPart, error) {
root, err := msg.RootPtr()
return JoinKeyPart{root.Struct()}, err
}
func (s JoinKeyPart) String() string {
str, _ := text.Marshal(0x95b29059097fca83, s.Struct)
return str
}
func (s JoinKeyPart) JoinId() uint32 {
return s.Struct.Uint32(0)
}
func (s JoinKeyPart) SetJoinId(v uint32) {
s.Struct.SetUint32(0, v)
}
func (s JoinKeyPart) PartCount() uint16 {
return s.Struct.Uint16(4)
}
func (s JoinKeyPart) SetPartCount(v uint16) {
s.Struct.SetUint16(4, v)
}
func (s JoinKeyPart) PartNum() uint16 {
return s.Struct.Uint16(6)
}
func (s JoinKeyPart) SetPartNum(v uint16) {
s.Struct.SetUint16(6, v)
}
// JoinKeyPart_List is a list of JoinKeyPart.
type JoinKeyPart_List struct{ capnp.List }
// NewJoinKeyPart creates a new list of JoinKeyPart.
func NewJoinKeyPart_List(s *capnp.Segment, sz int32) (JoinKeyPart_List, error) {
l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0}, sz)
return JoinKeyPart_List{l}, err
}
func (s JoinKeyPart_List) At(i int) JoinKeyPart { return JoinKeyPart{s.List.Struct(i)} }
func (s JoinKeyPart_List) Set(i int, v JoinKeyPart) error { return s.List.SetStruct(i, v.Struct) }
func (s JoinKeyPart_List) String() string {
str, _ := text.MarshalList(0x95b29059097fca83, s.List)
return str
}
// JoinKeyPart_Promise is a wrapper for a JoinKeyPart promised by a client call.
type JoinKeyPart_Promise struct{ *capnp.Pipeline }
func (p JoinKeyPart_Promise) Struct() (JoinKeyPart, error) {
s, err := p.Pipeline.Struct()
return JoinKeyPart{s}, err
}
type JoinResult struct{ capnp.Struct }
// JoinResult_TypeID is the unique identifier for the type JoinResult.
const JoinResult_TypeID = 0x9d263a3630b7ebee
func NewJoinResult(s *capnp.Segment) (JoinResult, error) {
st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 1})
return JoinResult{st}, err
}
func NewRootJoinResult(s *capnp.Segment) (JoinResult, error) {
st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 1})
return JoinResult{st}, err
}
func ReadRootJoinResult(msg *capnp.Message) (JoinResult, error) {
root, err := msg.RootPtr()
return JoinResult{root.Struct()}, err
}
func (s JoinResult) String() string {
str, _ := text.Marshal(0x9d263a3630b7ebee, s.Struct)
return str
}
func (s JoinResult) JoinId() uint32 {
return s.Struct.Uint32(0)
}
func (s JoinResult) SetJoinId(v uint32) {
s.Struct.SetUint32(0, v)
}
func (s JoinResult) Succeeded() bool {
return s.Struct.Bit(32)
}
func (s JoinResult) SetSucceeded(v bool) {
s.Struct.SetBit(32, v)
}
func (s JoinResult) Cap() (capnp.Pointer, error) {
return s.Struct.Pointer(0)
}
func (s JoinResult) HasCap() bool {
p, err := s.Struct.Ptr(0)
return p.IsValid() || err != nil
}
func (s JoinResult) CapPtr() (capnp.Ptr, error) {
return s.Struct.Ptr(0)
}
func (s JoinResult) SetCap(v capnp.Pointer) error {
return s.Struct.SetPointer(0, v)
}
func (s JoinResult) SetCapPtr(v capnp.Ptr) error {
return s.Struct.SetPtr(0, v)
}
// JoinResult_List is a list of JoinResult.
type JoinResult_List struct{ capnp.List }
// NewJoinResult creates a new list of JoinResult.
func NewJoinResult_List(s *capnp.Segment, sz int32) (JoinResult_List, error) {
l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 1}, sz)
return JoinResult_List{l}, err
}
func (s JoinResult_List) At(i int) JoinResult { return JoinResult{s.List.Struct(i)} }
func (s JoinResult_List) Set(i int, v JoinResult) error { return s.List.SetStruct(i, v.Struct) }
func (s JoinResult_List) String() string {
str, _ := text.MarshalList(0x9d263a3630b7ebee, s.List)
return str
}
// JoinResult_Promise is a wrapper for a JoinResult promised by a client call.
type JoinResult_Promise struct{ *capnp.Pipeline }
func (p JoinResult_Promise) Struct() (JoinResult, error) {
s, err := p.Pipeline.Struct()
return JoinResult{s}, err
}
func (p JoinResult_Promise) Cap() *capnp.Pipeline {
return p.Pipeline.GetPipeline(0)
}
const schema_a184c7885cdaf2a1 = "x\xda|\x92\xcfk\x13A\x14\xc7\xdfw&1\x09Z" +
"\xc2v\"\xa2\x17E\xd0\x83\xa8\xb4(\x0a\x0b\xb2\xc1 " +
"\xb8Z$\x13[\xb1`\x0f\xcb\xee\xa2+\xed\xeevw" +
"S\xc9A\x02*h\x0fJ/\x82\x07k\xe9\xd1\x93(" +
"\xfe*\xe8AA\x84\x1e=x\xf0_\x10zho\x01" +
"Y\x99\x05\x1b\xc9\x8f\xdef\x1e\x9f\xf7\xe5\xf3\xde\xcc\xd8" +
"9T\xd9x\xbe\x9d#\x92\xa7\xf3\xbb\xd2/\xf7\xaa\x7f" +
"\xde/n-\x92&\x90\xaen\xfe\xba\xf1\xe8\xfb\x83U" +
"\xca\x15\x88\xc4\x11\xd6\x11\xe3\xac@<\xbd\xbf\xde.M" +
"/\xbdyJR\xa0\x97\x1aa\x1d\xb1\x9f\xa9\xd3^\xf6" +
"\x8a\x90n\xfc\xfe0vF?\xba\xdc\xc3\xe6\xa1\x90\xd7" +
"lS|\xce\xe0\xb5\x0c~>\xbf\xf6\xf0\xd3\x8b\x9f+" +
"\xa4\x09\xd6e\x09b\x8a\x7f\x153\\\x81\xd3\xfc,!" +
"]~w\xfcf\xcbl\xbf\xed\xd7<5\xc3\x0f@\xcc" +
"q\xe5\xb9\xef\xd9\xd6\xb7\x97\xa5\xc7\x1f\x07y\x9a\xbc#" +
"\xa6\xb2D\xc9\x0dB\xfaD\x8f7V\x96v\xff\x18\xc4" +
"\xce\xf3uq7c[\xdc\xa0Z\x1a\x85\xf6\x89\xe4N" +
"\x102+JZ'm+\xf4C\xbd\xe1\xda^hx" +
"\xae\x9f\x98N\x1d\x18\xc8\\\x0a<\xff\xb2\xe1\xb6\xeaV" +
"\x94\xd4\x01\xb9\x87\xe7\x88r \xd2.\xe8D\xb2\xca!" +
"'\x184\xb0\x0aT\xd1l\x10\xc9\x8b\x1cr\x92Ac" +
"\xbc\x02F\xa4\xc9\xf3Dr\x82C^g0n\x07\x9e" +
"o:(\x12C\x91\x90\x86V\x94\xd4\x82\xa6OHP" +
" \x86\x02\xa1\xadjW\x9as\xff\xeeC\xbd\x1a\x07\xdd" +
"\xb89\xbb\xa3\xd6\xa1~-\xa5\x9aY\x1d\x1en\x157" +
"m\xdbu\x1d\x97\xe0\x00\xc4\x00B\xc1\xb6B\x8c\x12\xc3" +
"\xe8\x10\xa3\xab\x9e\xe3\x92r)f\xf1\x9aN\x04h%" +
"\x9d\xc8\x88\xddh\xc1\x8d\x0c{V\xedz\xbb\x99\xff\xd7" +
"<y\xcb\x8b\x1c\xb5\xe3V\xcd\x0a\xf9\xf0\xe7\xa8G\xc1" +
"\x82g\xc4^\xe0g\x8c\xccm\xcf=\xa2\xe6.r\xc8" +
"J\xff8\x83\x92\xaeY\x89\xe9\x10\xf5\x84\x1c\xeb\x86\x94" +
"c\xcfqQ\xee~p\x02\xca\x84\xbf\x01\x00\x00\xff\xff" +
"+!\xf3\xa9"
func init() {
schemas.Register(schema_a184c7885cdaf2a1,
0x89f389b6fd4082c1,
0x95b29059097fca83,
0x9d263a3630b7ebee,
0x9fd69ebc87b9719c,
0xb47f4979672cb59d,
0xb88d09a9c5f39817,
0xd20b909fee733a8e)
}

View File

@@ -0,0 +1,487 @@
# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
# Licensed under the MIT License:
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
using Cxx = import "/capnp/c++.capnp";
@0xa93fc509624c72d9;
$Cxx.namespace("capnp::schema");
using Id = UInt64;
# The globally-unique ID of a file, type, or annotation.
struct Node {
id @0 :Id;
displayName @1 :Text;
# Name to present to humans to identify this Node. You should not attempt to parse this. Its
# format could change. It is not guaranteed to be unique.
#
# (On Zooko's triangle, this is the node's nickname.)
displayNamePrefixLength @2 :UInt32;
# If you want a shorter version of `displayName` (just naming this node, without its surrounding
# scope), chop off this many characters from the beginning of `displayName`.
scopeId @3 :Id;
# ID of the lexical parent node. Typically, the scope node will have a NestedNode pointing back
# at this node, but robust code should avoid relying on this (and, in fact, group nodes are not
# listed in the outer struct's nestedNodes, since they are listed in the fields). `scopeId` is
# zero if the node has no parent, which is normally only the case with files, but should be
# allowed for any kind of node (in order to make runtime type generation easier).
parameters @32 :List(Parameter);
# If this node is parameterized (generic), the list of parameters. Empty for non-generic types.
isGeneric @33 :Bool;
# True if this node is generic, meaning that it or one of its parent scopes has a non-empty
# `parameters`.
struct Parameter {
# Information about one of the node's parameters.
name @0 :Text;
}
nestedNodes @4 :List(NestedNode);
# List of nodes nested within this node, along with the names under which they were declared.
struct NestedNode {
name @0 :Text;
# Unqualified symbol name. Unlike Node.displayName, this *can* be used programmatically.
#
# (On Zooko's triangle, this is the node's petname according to its parent scope.)
id @1 :Id;
# ID of the nested node. Typically, the target node's scopeId points back to this node, but
# robust code should avoid relying on this.
}
annotations @5 :List(Annotation);
# Annotations applied to this node.
union {
# Info specific to each kind of node.
file @6 :Void;
struct :group $Go.name("structNode") {
dataWordCount @7 :UInt16;
# Size of the data section, in words.
pointerCount @8 :UInt16;
# Size of the pointer section, in pointers (which are one word each).
preferredListEncoding @9 :ElementSize;
# The preferred element size to use when encoding a list of this struct. If this is anything
# other than `inlineComposite` then the struct is one word or less in size and is a candidate
# for list packing optimization.
isGroup @10 :Bool;
# If true, then this "struct" node is actually not an independent node, but merely represents
# some named union or group within a particular parent struct. This node's scopeId refers
# to the parent struct, which may itself be a union/group in yet another struct.
#
# All group nodes share the same dataWordCount and pointerCount as the top-level
# struct, and their fields live in the same ordinal and offset spaces as all other fields in
# the struct.
#
# Note that a named union is considered a special kind of group -- in fact, a named union
# is exactly equivalent to a group that contains nothing but an unnamed union.
discriminantCount @11 :UInt16;
# Number of fields in this struct which are members of an anonymous union, and thus may
# overlap. If this is non-zero, then a 16-bit discriminant is present indicating which
# of the overlapping fields is active. This can never be 1 -- if it is non-zero, it must be
# two or more.
#
# Note that the fields of an unnamed union are considered fields of the scope containing the
# union -- an unnamed union is not its own group. So, a top-level struct may contain a
# non-zero discriminant count. Named unions, on the other hand, are equivalent to groups
# containing unnamed unions. So, a named union has its own independent schema node, with
# `isGroup` = true.
discriminantOffset @12 :UInt32;
# If `discriminantCount` is non-zero, this is the offset of the union discriminant, in
# multiples of 16 bits.
fields @13 :List(Field);
# Fields defined within this scope (either the struct's top-level fields, or the fields of
# a particular group; see `isGroup`).
#
# The fields are sorted by ordinal number, but note that because groups share the same
# ordinal space, the field's index in this list is not necessarily exactly its ordinal.
# On the other hand, the field's position in this list does remain the same even as the
# protocol evolves, since it is not possible to insert or remove an earlier ordinal.
# Therefore, for most use cases, if you want to identify a field by number, it may make the
# most sense to use the field's index in this list rather than its ordinal.
}
enum :group {
enumerants@14 :List(Enumerant);
# Enumerants ordered by numeric value (ordinal).
}
interface :group {
methods @15 :List(Method);
# Methods ordered by ordinal.
superclasses @31 :List(Superclass);
# Superclasses of this interface.
}
const :group {
type @16 :Type;
value @17 :Value;
}
annotation :group {
type @18 :Type;
targetsFile @19 :Bool;
targetsConst @20 :Bool;
targetsEnum @21 :Bool;
targetsEnumerant @22 :Bool;
targetsStruct @23 :Bool;
targetsField @24 :Bool;
targetsUnion @25 :Bool;
targetsGroup @26 :Bool;
targetsInterface @27 :Bool;
targetsMethod @28 :Bool;
targetsParam @29 :Bool;
targetsAnnotation @30 :Bool;
}
}
}
struct Field {
# Schema for a field of a struct.
name @0 :Text;
codeOrder @1 :UInt16;
# Indicates where this member appeared in the code, relative to other members.
# Code ordering may have semantic relevance -- programmers tend to place related fields
# together. So, using code ordering makes sense in human-readable formats where ordering is
# otherwise irrelevant, like JSON. The values of codeOrder are tightly-packed, so the maximum
# value is count(members) - 1. Fields that are members of a union are only ordered relative to
# the other members of that union, so the maximum value there is count(union.members).
annotations @2 :List(Annotation);
const noDiscriminant :UInt16 = 0xffff;
discriminantValue @3 :UInt16 = Field.noDiscriminant;
# If the field is in a union, this is the value which the union's discriminant should take when
# the field is active. If the field is not in a union, this is 0xffff.
union {
slot :group {
# A regular, non-group, non-fixed-list field.
offset @4 :UInt32;
# Offset, in units of the field's size, from the beginning of the section in which the field
# resides. E.g. for a UInt32 field, multiply this by 4 to get the byte offset from the
# beginning of the data section.
type @5 :Type;
defaultValue @6 :Value;
hadExplicitDefault @10 :Bool;
# Whether the default value was specified explicitly. Non-explicit default values are always
# zero or empty values. Usually, whether the default value was explicit shouldn't matter.
# The main use case for this flag is for structs representing method parameters:
# explicitly-defaulted parameters may be allowed to be omitted when calling the method.
}
group :group {
# A group.
typeId @7 :Id;
# The ID of the group's node.
}
}
ordinal :union {
implicit @8 :Void;
explicit @9 :UInt16;
# The original ordinal number given to the field. You probably should NOT use this; if you need
# a numeric identifier for a field, use its position within the field array for its scope.
# The ordinal is given here mainly just so that the original schema text can be reproduced given
# the compiled version -- i.e. so that `capnp compile -ocapnp` can do its job.
}
}
struct Enumerant {
# Schema for member of an enum.
name @0 :Text;
codeOrder @1 :UInt16;
# Specifies order in which the enumerants were declared in the code.
# Like Struct.Field.codeOrder.
annotations @2 :List(Annotation);
}
struct Superclass {
id @0 :Id;
brand @1 :Brand;
}
struct Method {
# Schema for method of an interface.
name @0 :Text;
codeOrder @1 :UInt16;
# Specifies order in which the methods were declared in the code.
# Like Struct.Field.codeOrder.
implicitParameters @7 :List(Node.Parameter);
# The parameters listed in [] (typically, type / generic parameters), whose bindings are intended
# to be inferred rather than specified explicitly, although not all languages support this.
paramStructType @2 :Id;
# ID of the parameter struct type. If a named parameter list was specified in the method
# declaration (rather than a single struct parameter type) then a corresponding struct type is
# auto-generated. Such an auto-generated type will not be listed in the interface's
# `nestedNodes` and its `scopeId` will be zero -- it is completely detached from the namespace.
# (Awkwardly, it does of course inherit generic parameters from the method's scope, which makes
# this a situation where you can't just climb the scope chain to find where a particular
# generic parameter was introduced. Making the `scopeId` zero was a mistake.)
paramBrand @5 :Brand;
# Brand of param struct type.
resultStructType @3 :Id;
# ID of the return struct type; similar to `paramStructType`.
resultBrand @6 :Brand;
# Brand of result struct type.
annotations @4 :List(Annotation);
}
struct Type {
# Represents a type expression.
union {
# The ordinals intentionally match those of Value.
void @0 :Void;
bool @1 :Void;
int8 @2 :Void;
int16 @3 :Void;
int32 @4 :Void;
int64 @5 :Void;
uint8 @6 :Void;
uint16 @7 :Void;
uint32 @8 :Void;
uint64 @9 :Void;
float32 @10 :Void;
float64 @11 :Void;
text @12 :Void;
data @13 :Void;
list :group {
elementType @14 :Type;
}
enum :group {
typeId @15 :Id;
brand @21 :Brand;
}
struct :group $Go.name("structType") {
typeId @16 :Id;
brand @22 :Brand;
}
interface :group {
typeId @17 :Id;
brand @23 :Brand;
}
anyPointer :union {
unconstrained :union {
# A regular AnyPointer.
#
# The name "unconstained" means as opposed to constraining it to match a type parameter.
# In retrospect this name is probably a poor choice given that it may still be constrained
# to be a struct, list, or capability.
anyKind @18 :Void; # truly AnyPointer
struct @25 :Void; # AnyStruct
list @26 :Void; # AnyList
capability @27 :Void; # Capability
}
parameter :group {
# This is actually a reference to a type parameter defined within this scope.
scopeId @19 :Id;
# ID of the generic type whose parameter we're referencing. This should be a parent of the
# current scope.
parameterIndex @20 :UInt16;
# Index of the parameter within the generic type's parameter list.
}
implicitMethodParameter :group {
# This is actually a reference to an implicit (generic) parameter of a method. The only
# legal context for this type to appear is inside Method.paramBrand or Method.resultBrand.
parameterIndex @24 :UInt16;
}
}
}
}
struct Brand {
# Specifies bindings for parameters of generics. Since these bindings turn a generic into a
# non-generic, we call it the "brand".
scopes @0 :List(Scope);
# For each of the target type and each of its parent scopes, a parameterization may be included
# in this list. If no parameterization is included for a particular relevant scope, then either
# that scope has no parameters or all parameters should be considered to be `AnyPointer`.
struct Scope {
scopeId @0 :Id;
# ID of the scope to which these params apply.
union {
bind @1 :List(Binding);
# List of parameter bindings.
inherit @2 :Void;
# The place where this Brand appears is actually within this scope or a sub-scope,
# and the bindings for this scope should be inherited from the reference point.
}
}
struct Binding {
union {
unbound @0 :Void;
type @1 :Type;
# TODO(someday): Allow non-type parameters? Unsure if useful.
}
}
}
struct Value {
# Represents a value, e.g. a field default value, constant value, or annotation value.
union {
# The ordinals intentionally match those of Type.
void @0 :Void;
bool @1 :Bool;
int8 @2 :Int8;
int16 @3 :Int16;
int32 @4 :Int32;
int64 @5 :Int64;
uint8 @6 :UInt8;
uint16 @7 :UInt16;
uint32 @8 :UInt32;
uint64 @9 :UInt64;
float32 @10 :Float32;
float64 @11 :Float64;
text @12 :Text;
data @13 :Data;
list @14 :AnyPointer;
enum @15 :UInt16;
struct @16 :AnyPointer $Go.name("structValue");
interface @17 :Void;
# The only interface value that can be represented statically is "null", whose methods always
# throw exceptions.
anyPointer @18 :AnyPointer;
}
}
struct Annotation {
# Describes an annotation applied to a declaration. Note AnnotationNode describes the
# annotation's declaration, while this describes a use of the annotation.
id @0 :Id;
# ID of the annotation node.
brand @2 :Brand;
# Brand of the annotation.
#
# Note that the annotation itself is not allowed to be parameterized, but its scope might be.
value @1 :Value;
}
enum ElementSize {
# Possible element sizes for encoded lists. These correspond exactly to the possible values of
# the 3-bit element size component of a list pointer.
empty @0; # aka "void", but that's a keyword.
bit @1;
byte @2;
twoBytes @3;
fourBytes @4;
eightBytes @5;
pointer @6;
inlineComposite @7;
}
struct CodeGeneratorRequest {
nodes @0 :List(Node);
# All nodes parsed by the compiler, including for the files on the command line and their
# imports.
requestedFiles @1 :List(RequestedFile);
# Files which were listed on the command line.
struct RequestedFile {
id @0 :Id;
# ID of the file.
filename @1 :Text;
# Name of the file as it appeared on the command-line (minus the src-prefix). You may use
# this to decide where to write the output.
imports @2 :List(Import);
# List of all imported paths seen in this file.
struct Import {
id @0 :Id;
# ID of the imported file.
name @1 :Text;
# Name which *this* file used to refer to the foreign file. This may be a relative name.
# This information is provided because it might be useful for code generation, e.g. to
# generate #include directives in C++. We don't put this in Node.file because this
# information is only meaningful at compile time anyway.
#
# (On Zooko's triangle, this is the import's petname according to the importing file.)
}
}
}
using Go = import "/go.capnp";
$Go.package("schema");
$Go.import("zombiezen.com/go/capnproto2/std/capnp/schema");

View File

@@ -0,0 +1,13 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["schema.capnp.go"],
importpath = "zombiezen.com/go/capnproto2/std/capnp/schema",
visibility = ["//visibility:public"],
deps = [
"//:go_default_library",
"//encoding/text:go_default_library",
"//schemas:go_default_library",
],
)

File diff suppressed because it is too large Load Diff

27
vendor/zombiezen.com/go/capnproto2/std/go.capnp generated vendored Normal file
View File

@@ -0,0 +1,27 @@
@0xd12a1c51fedd6c88;
annotation package(file) :Text;
# The Go package name for the generated file.
annotation import(file) :Text;
# The Go import path that the generated file is accessible from.
# Used to generate import statements and check if two types are in the
# same package.
annotation doc(struct, field, enum) :Text;
# Adds a doc comment to the generated code.
annotation tag(enumerant) :Text;
# Changes the string representation of the enum in the generated code.
annotation notag(enumerant) :Void;
# Removes the string representation of the enum in the generated code.
annotation customtype(field) :Text;
# OBSOLETE, not used by code generator.
annotation name(struct, field, union, enum, enumerant, interface, method, param, annotation, const, group) :Text;
# Used to rename the element in the generated code.
$package("capnp");
$import("zombiezen.com/go/capnproto2");