Skip to content

Commit

Permalink
fix(provider): comment out WIT impl
Browse files Browse the repository at this point in the history
Signed-off-by: Brooks Townsend <brooksmtownsend@gmail.com>
  • Loading branch information
brooksmtownsend committed Jul 3, 2024
1 parent 951f64b commit f86d427
Show file tree
Hide file tree
Showing 8 changed files with 30,256 additions and 5 deletions.
8,377 changes: 8,377 additions & 0 deletions bindings/exports/wasmcloud/couchbase/document/bindings.wrpc.go

Large diffs are not rendered by default.

6,815 changes: 6,815 additions & 0 deletions bindings/exports/wasmcloud/couchbase/fts/bindings.wrpc.go

Large diffs are not rendered by default.

1,512 changes: 1,512 additions & 0 deletions bindings/exports/wasmcloud/couchbase/sqlpp/bindings.wrpc.go

Large diffs are not rendered by default.

3,855 changes: 3,855 additions & 0 deletions bindings/exports/wasmcloud/couchbase/subdocument_lookup/bindings.wrpc.go

Large diffs are not rendered by default.

7,404 changes: 7,404 additions & 0 deletions bindings/exports/wasmcloud/couchbase/subdocument_mutate/bindings.wrpc.go

Large diffs are not rendered by default.

178 changes: 178 additions & 0 deletions bindings/wasmcloud/couchbase/sqlpp_types/bindings.wrpc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
// Generated by `wit-bindgen-wrpc-go` 0.1.1. DO NOT EDIT!
package sqlpp_types

import (
binary "encoding/binary"
errors "errors"
fmt "fmt"
wrpc "github.com/wrpc/wrpc/go"
io "io"
slog "log/slog"
math "math"
)

// Errors that can occur when a SQL++ query is performed
type SqlppQueryError struct {
payload any
discriminant SqlppQueryErrorDiscriminant
}

func (v *SqlppQueryError) Discriminant() SqlppQueryErrorDiscriminant { return v.discriminant }

type SqlppQueryErrorDiscriminant uint8

const (
// A completely unexpected query error
SqlppQueryErrorUnexpected SqlppQueryErrorDiscriminant = 0
)

func (v *SqlppQueryError) String() string {
switch v.discriminant {
case SqlppQueryErrorUnexpected:
return "unexpected"
default:
panic("invalid variant")
}
}

// A completely unexpected query error
func (v *SqlppQueryError) GetUnexpected() (payload string, ok bool) {
if ok = (v.discriminant == SqlppQueryErrorUnexpected); !ok {
return
}
payload, ok = v.payload.(string)
return
}

// A completely unexpected query error
func (v *SqlppQueryError) SetUnexpected(payload string) *SqlppQueryError {
v.discriminant = SqlppQueryErrorUnexpected
v.payload = payload
return v
}

// A completely unexpected query error
func NewSqlppQueryErrorUnexpected(payload string) *SqlppQueryError {
return (&SqlppQueryError{}).SetUnexpected(
payload)
}
func (v *SqlppQueryError) Error() string { return v.String() }
func (v *SqlppQueryError) WriteToIndex(w wrpc.ByteWriter) (func(wrpc.IndexWriter) error, error) {
if err := func(v uint8, w io.Writer) error {
b := make([]byte, 2)
i := binary.PutUvarint(b, uint64(v))
slog.Debug("writing u8 discriminant")
_, err := w.Write(b[:i])
return err
}(uint8(v.discriminant), w); err != nil {
return nil, fmt.Errorf("failed to write discriminant: %w", err)
}
switch v.discriminant {
case SqlppQueryErrorUnexpected:
payload, ok := v.payload.(string)
if !ok {
return nil, errors.New("invalid payload")
}
write, err := (func(wrpc.IndexWriter) error)(nil), func(v string, w io.Writer) (err error) {
n := len(v)
if n > math.MaxUint32 {
return fmt.Errorf("string byte length of %d overflows a 32-bit integer", n)
}
if err = func(v int, w io.Writer) error {
b := make([]byte, binary.MaxVarintLen32)
i := binary.PutUvarint(b, uint64(v))
slog.Debug("writing string byte length", "len", n)
_, err = w.Write(b[:i])
return err
}(n, w); err != nil {
return fmt.Errorf("failed to write string byte length of %d: %w", n, err)
}
slog.Debug("writing string bytes")
_, err = w.Write([]byte(v))
if err != nil {
return fmt.Errorf("failed to write string bytes: %w", err)
}
return nil
}(payload, w)
if err != nil {
return nil, fmt.Errorf("failed to write payload: %w", err)
}

if write != nil {
return func(w wrpc.IndexWriter) error {
w, err := w.Index(0)
if err != nil {
return fmt.Errorf("failed to index writer: %w", err)
}
return write(w)
}, nil
}
default:
return nil, errors.New("invalid variant")
}
return nil, nil
}

// An embedding of SQL++ values to WebAssembly types
//
// This type should be used in building queries, and also in parsing/processing results,
// as it is used for both parameters and returned results from queries.
type SqlppValue struct {
payload any
discriminant SqlppValueDiscriminant
}

func (v *SqlppValue) Discriminant() SqlppValueDiscriminant { return v.discriminant }

type SqlppValueDiscriminant uint8

const (
// A NULL value
SqlppValueNull SqlppValueDiscriminant = 0
)

func (v *SqlppValue) String() string {
switch v.discriminant {
case SqlppValueNull:
return "null"
default:
panic("invalid variant")
}
}

// A NULL value
func (v *SqlppValue) GetNull() (ok bool) {
if ok = (v.discriminant == SqlppValueNull); !ok {
return
}
return
}

// A NULL value
func (v *SqlppValue) SetNull() *SqlppValue {
v.discriminant = SqlppValueNull
v.payload = nil
return v
}

// A NULL value
func NewSqlppValueNull() *SqlppValue {
return (&SqlppValue{}).SetNull()
}
func (v *SqlppValue) WriteToIndex(w wrpc.ByteWriter) (func(wrpc.IndexWriter) error, error) {
if err := func(v uint8, w io.Writer) error {
b := make([]byte, 2)
i := binary.PutUvarint(b, uint64(v))
slog.Debug("writing u8 discriminant")
_, err := w.Write(b[:i])
return err
}(uint8(v.discriminant), w); err != nil {
return nil, fmt.Errorf("failed to write discriminant: %w", err)
}
switch v.discriminant {
case SqlppValueNull:
default:
return nil, errors.New("invalid variant")
}
return nil, nil
}
Loading

0 comments on commit f86d427

Please sign in to comment.