// Generated by `wit-bindgen-wrpc-go` 0.1.1. DO NOT EDIT! package monotonic_clock import ( bytes "bytes" context "context" binary "encoding/binary" errors "errors" fmt "fmt" wasi__io__poll "github.com/wrpc/wit-bindgen-wrpc/examples/go/http-outgoing-server/bindings/wasi/io/poll" wrpc "github.com/wrpc/wrpc/go" io "io" slog "log/slog" utf8 "unicode/utf8" ) type Pollable = wasi__io__poll.Pollable // An instant in time, in nanoseconds. An instant is relative to an // unspecified initial value, and can only be compared to instances from // the same monotonic-clock. type Instant = uint64 // A duration of time, in nanoseconds. type Duration = uint64 // Read the current value of the clock. // // The clock is monotonic, therefore calling this function repeatedly will // produce a sequence of non-decreasing values. func Now(ctx__ context.Context, wrpc__ wrpc.Invoker) (r0__ uint64, close__ func() error, err__ error) { if err__ = wrpc__.Invoke(ctx__, "wasi:clocks/monotonic-clock@0.2.0", "now", func(w__ wrpc.IndexWriter, r__ wrpc.IndexReadCloser) error { close__ = r__.Close _, err__ = w__.Write(nil) if err__ != nil { return fmt.Errorf("failed to write empty parameters: %w", err__) } r0__, err__ = func() (Instant, error) { v, err := func(r io.ByteReader) (uint64, error) { var x uint64 var s uint8 for i := 0; i < 10; i++ { slog.Debug("reading u64 byte", "i", i) b, err := r.ReadByte() if err != nil { if i > 0 && err == io.EOF { err = io.ErrUnexpectedEOF } return x, fmt.Errorf("failed to read u64 byte: %w", err) } if s == 63 && b > 0x01 { return x, errors.New("varint overflows a 64-bit integer") } if b < 0x80 { return x | uint64(b)< 0 && err == io.EOF { err = io.ErrUnexpectedEOF } return x, fmt.Errorf("failed to read u64 byte: %w", err) } if s == 63 && b > 0x01 { return x, errors.New("varint overflows a 64-bit integer") } if b < 0x80 { return x | uint64(b)< 0 && err == io.EOF { err = io.ErrUnexpectedEOF } return "", fmt.Errorf("failed to read owned resource ID length byte: %w", err) } if b < 0x80 { if i == 4 && b > 1 { return "", errors.New("owned resource ID length overflows a 32-bit integer") } x = x | uint32(b)< 0 && err == io.EOF { err = io.ErrUnexpectedEOF } return "", fmt.Errorf("failed to read owned resource ID length byte: %w", err) } if b < 0x80 { if i == 4 && b > 1 { return "", errors.New("owned resource ID length overflows a 32-bit integer") } x = x | uint32(b)<