| // Copyright 2015 The Vanadium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| |
| // This file was auto-generated by the vanadium vdl tool. |
| // Package: server |
| |
| package server |
| |
| import ( |
| "fmt" |
| "v.io/v23/security/access" |
| "v.io/v23/vdl" |
| ) |
| |
| var _ = __VDLInit() // Must be first; see __VDLInit comments for details. |
| |
| ////////////////////////////////////////////////// |
| // Type definitions |
| |
| // ServiceData represents the persistent state of a Service. |
| type ServiceData struct { |
| Version uint64 // covers the fields below |
| Perms access.Permissions |
| } |
| |
| func (ServiceData) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server.ServiceData"` |
| }) { |
| } |
| |
| func (m *ServiceData) FillVDLTarget(t vdl.Target, tt *vdl.Type) error { |
| fieldsTarget1, err := t.StartFields(tt) |
| if err != nil { |
| return err |
| } |
| |
| keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Version") |
| if err != vdl.ErrFieldNoExist && err != nil { |
| return err |
| } |
| if err != vdl.ErrFieldNoExist { |
| if err := fieldTarget3.FromUint(uint64(m.Version), tt.NonOptional().Field(0).Type); err != nil { |
| return err |
| } |
| if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil { |
| return err |
| } |
| } |
| keyTarget4, fieldTarget5, err := fieldsTarget1.StartField("Perms") |
| if err != vdl.ErrFieldNoExist && err != nil { |
| return err |
| } |
| if err != vdl.ErrFieldNoExist { |
| |
| if err := m.Perms.FillVDLTarget(fieldTarget5, tt.NonOptional().Field(1).Type); err != nil { |
| return err |
| } |
| if err := fieldsTarget1.FinishField(keyTarget4, fieldTarget5); err != nil { |
| return err |
| } |
| } |
| if err := t.FinishFields(fieldsTarget1); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| func (m *ServiceData) MakeVDLTarget() vdl.Target { |
| return &ServiceDataTarget{Value: m} |
| } |
| |
| type ServiceDataTarget struct { |
| Value *ServiceData |
| versionTarget vdl.Uint64Target |
| permsTarget access.PermissionsTarget |
| vdl.TargetBase |
| vdl.FieldsTargetBase |
| } |
| |
| func (t *ServiceDataTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) { |
| |
| if ttWant := vdl.TypeOf((*ServiceData)(nil)).Elem(); !vdl.Compatible(tt, ttWant) { |
| return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant) |
| } |
| return t, nil |
| } |
| func (t *ServiceDataTarget) StartField(name string) (key, field vdl.Target, _ error) { |
| switch name { |
| case "Version": |
| t.versionTarget.Value = &t.Value.Version |
| target, err := &t.versionTarget, error(nil) |
| return nil, target, err |
| case "Perms": |
| t.permsTarget.Value = &t.Value.Perms |
| target, err := &t.permsTarget, error(nil) |
| return nil, target, err |
| default: |
| return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/services/syncbase/server.ServiceData", name) |
| } |
| } |
| func (t *ServiceDataTarget) FinishField(_, _ vdl.Target) error { |
| return nil |
| } |
| func (t *ServiceDataTarget) FinishFields(_ vdl.FieldsTarget) error { |
| |
| return nil |
| } |
| |
| // AppData represents the persistent state of an App. |
| type AppData struct { |
| Name string |
| Version uint64 // covers the fields below |
| Perms access.Permissions |
| } |
| |
| func (AppData) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server.AppData"` |
| }) { |
| } |
| |
| func (m *AppData) FillVDLTarget(t vdl.Target, tt *vdl.Type) error { |
| fieldsTarget1, err := t.StartFields(tt) |
| if err != nil { |
| return err |
| } |
| |
| keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Name") |
| if err != vdl.ErrFieldNoExist && err != nil { |
| return err |
| } |
| if err != vdl.ErrFieldNoExist { |
| if err := fieldTarget3.FromString(string(m.Name), tt.NonOptional().Field(0).Type); err != nil { |
| return err |
| } |
| if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil { |
| return err |
| } |
| } |
| keyTarget4, fieldTarget5, err := fieldsTarget1.StartField("Version") |
| if err != vdl.ErrFieldNoExist && err != nil { |
| return err |
| } |
| if err != vdl.ErrFieldNoExist { |
| if err := fieldTarget5.FromUint(uint64(m.Version), tt.NonOptional().Field(1).Type); err != nil { |
| return err |
| } |
| if err := fieldsTarget1.FinishField(keyTarget4, fieldTarget5); err != nil { |
| return err |
| } |
| } |
| keyTarget6, fieldTarget7, err := fieldsTarget1.StartField("Perms") |
| if err != vdl.ErrFieldNoExist && err != nil { |
| return err |
| } |
| if err != vdl.ErrFieldNoExist { |
| |
| if err := m.Perms.FillVDLTarget(fieldTarget7, tt.NonOptional().Field(2).Type); err != nil { |
| return err |
| } |
| if err := fieldsTarget1.FinishField(keyTarget6, fieldTarget7); err != nil { |
| return err |
| } |
| } |
| if err := t.FinishFields(fieldsTarget1); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| func (m *AppData) MakeVDLTarget() vdl.Target { |
| return &AppDataTarget{Value: m} |
| } |
| |
| type AppDataTarget struct { |
| Value *AppData |
| nameTarget vdl.StringTarget |
| versionTarget vdl.Uint64Target |
| permsTarget access.PermissionsTarget |
| vdl.TargetBase |
| vdl.FieldsTargetBase |
| } |
| |
| func (t *AppDataTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) { |
| |
| if ttWant := vdl.TypeOf((*AppData)(nil)).Elem(); !vdl.Compatible(tt, ttWant) { |
| return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant) |
| } |
| return t, nil |
| } |
| func (t *AppDataTarget) StartField(name string) (key, field vdl.Target, _ error) { |
| switch name { |
| case "Name": |
| t.nameTarget.Value = &t.Value.Name |
| target, err := &t.nameTarget, error(nil) |
| return nil, target, err |
| case "Version": |
| t.versionTarget.Value = &t.Value.Version |
| target, err := &t.versionTarget, error(nil) |
| return nil, target, err |
| case "Perms": |
| t.permsTarget.Value = &t.Value.Perms |
| target, err := &t.permsTarget, error(nil) |
| return nil, target, err |
| default: |
| return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/services/syncbase/server.AppData", name) |
| } |
| } |
| func (t *AppDataTarget) FinishField(_, _ vdl.Target) error { |
| return nil |
| } |
| func (t *AppDataTarget) FinishFields(_ vdl.FieldsTarget) error { |
| |
| return nil |
| } |
| |
| // DbInfo contains information about one database for an App. |
| // TODO(sadovsky): Track NoSQL vs. SQL. |
| type DbInfo struct { |
| Name string |
| // Select fields from nosql.DatabaseOptions, needed in order to open storage |
| // engine on restart. |
| RootDir string // interpreted by storage engine |
| Engine string // name of storage engine, e.g. "leveldb" |
| } |
| |
| func (DbInfo) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server.DbInfo"` |
| }) { |
| } |
| |
| func (m *DbInfo) FillVDLTarget(t vdl.Target, tt *vdl.Type) error { |
| fieldsTarget1, err := t.StartFields(tt) |
| if err != nil { |
| return err |
| } |
| |
| keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Name") |
| if err != vdl.ErrFieldNoExist && err != nil { |
| return err |
| } |
| if err != vdl.ErrFieldNoExist { |
| if err := fieldTarget3.FromString(string(m.Name), tt.NonOptional().Field(0).Type); err != nil { |
| return err |
| } |
| if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil { |
| return err |
| } |
| } |
| keyTarget4, fieldTarget5, err := fieldsTarget1.StartField("RootDir") |
| if err != vdl.ErrFieldNoExist && err != nil { |
| return err |
| } |
| if err != vdl.ErrFieldNoExist { |
| if err := fieldTarget5.FromString(string(m.RootDir), tt.NonOptional().Field(1).Type); err != nil { |
| return err |
| } |
| if err := fieldsTarget1.FinishField(keyTarget4, fieldTarget5); err != nil { |
| return err |
| } |
| } |
| keyTarget6, fieldTarget7, err := fieldsTarget1.StartField("Engine") |
| if err != vdl.ErrFieldNoExist && err != nil { |
| return err |
| } |
| if err != vdl.ErrFieldNoExist { |
| if err := fieldTarget7.FromString(string(m.Engine), tt.NonOptional().Field(2).Type); err != nil { |
| return err |
| } |
| if err := fieldsTarget1.FinishField(keyTarget6, fieldTarget7); err != nil { |
| return err |
| } |
| } |
| if err := t.FinishFields(fieldsTarget1); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| func (m *DbInfo) MakeVDLTarget() vdl.Target { |
| return &DbInfoTarget{Value: m} |
| } |
| |
| type DbInfoTarget struct { |
| Value *DbInfo |
| nameTarget vdl.StringTarget |
| rootDirTarget vdl.StringTarget |
| engineTarget vdl.StringTarget |
| vdl.TargetBase |
| vdl.FieldsTargetBase |
| } |
| |
| func (t *DbInfoTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) { |
| |
| if ttWant := vdl.TypeOf((*DbInfo)(nil)).Elem(); !vdl.Compatible(tt, ttWant) { |
| return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant) |
| } |
| return t, nil |
| } |
| func (t *DbInfoTarget) StartField(name string) (key, field vdl.Target, _ error) { |
| switch name { |
| case "Name": |
| t.nameTarget.Value = &t.Value.Name |
| target, err := &t.nameTarget, error(nil) |
| return nil, target, err |
| case "RootDir": |
| t.rootDirTarget.Value = &t.Value.RootDir |
| target, err := &t.rootDirTarget, error(nil) |
| return nil, target, err |
| case "Engine": |
| t.engineTarget.Value = &t.Value.Engine |
| target, err := &t.engineTarget, error(nil) |
| return nil, target, err |
| default: |
| return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/services/syncbase/server.DbInfo", name) |
| } |
| } |
| func (t *DbInfoTarget) FinishField(_, _ vdl.Target) error { |
| return nil |
| } |
| func (t *DbInfoTarget) FinishFields(_ vdl.FieldsTarget) error { |
| |
| return nil |
| } |
| |
| // Create zero values for each type. |
| var ( |
| __VDLZeroServiceData = ServiceData{} |
| __VDLZeroAppData = AppData{} |
| __VDLZeroDbInfo = DbInfo{} |
| ) |
| |
| var __VDLInitCalled bool |
| |
| // __VDLInit performs vdl initialization. It is safe to call multiple times. |
| // If you have an init ordering issue, just insert the following line verbatim |
| // into your source files in this package, right after the "package foo" clause: |
| // |
| // var _ = __VDLInit() |
| // |
| // The purpose of this function is to ensure that vdl initialization occurs in |
| // the right order, and very early in the init sequence. In particular, vdl |
| // registration and package variable initialization needs to occur before |
| // functions like vdl.TypeOf will work properly. |
| // |
| // This function returns a dummy value, so that it can be used to initialize the |
| // first var in the file, to take advantage of Go's defined init order. |
| func __VDLInit() struct{} { |
| if __VDLInitCalled { |
| return struct{}{} |
| } |
| |
| // Register types. |
| vdl.Register((*ServiceData)(nil)) |
| vdl.Register((*AppData)(nil)) |
| vdl.Register((*DbInfo)(nil)) |
| |
| return struct{}{} |
| } |