// This file was auto-generated by the veyron vdl tool.
// Source: p2b.vdl

// Package vdl is an example of a veyron service for
// streaming data from a pipe to a browser, which can visualize this
// data.
package vdl

import (
	// VDL system imports
	"io"
	"v.io/core/veyron2"
	"v.io/core/veyron2/context"
	"v.io/core/veyron2/ipc"
	"v.io/core/veyron2/vdl"
)

// ViewerClientMethods is the client interface
// containing Viewer methods.
//
// Viewer allows clients to stream data to it and to request a
// particular viewer to format and display the data.
type ViewerClientMethods interface {
	// Pipe creates a bidirectional pipe between client and viewer
	// service, returns total number of bytes received by the service
	// after streaming ends
	Pipe(*context.T, ...ipc.CallOpt) (ViewerPipeCall, error)
}

// ViewerClientStub adds universal methods to ViewerClientMethods.
type ViewerClientStub interface {
	ViewerClientMethods
	ipc.UniversalServiceMethods
}

// ViewerClient returns a client stub for Viewer.
func ViewerClient(name string, opts ...ipc.BindOpt) ViewerClientStub {
	var client ipc.Client
	for _, opt := range opts {
		if clientOpt, ok := opt.(ipc.Client); ok {
			client = clientOpt
		}
	}
	return implViewerClientStub{name, client}
}

type implViewerClientStub struct {
	name   string
	client ipc.Client
}

func (c implViewerClientStub) c(ctx *context.T) ipc.Client {
	if c.client != nil {
		return c.client
	}
	return veyron2.GetClient(ctx)
}

func (c implViewerClientStub) Pipe(ctx *context.T, opts ...ipc.CallOpt) (ocall ViewerPipeCall, err error) {
	var call ipc.Call
	if call, err = c.c(ctx).StartCall(ctx, c.name, "Pipe", nil, opts...); err != nil {
		return
	}
	ocall = &implViewerPipeCall{Call: call}
	return
}

// ViewerPipeClientStream is the client stream for Viewer.Pipe.
type ViewerPipeClientStream interface {
	// SendStream returns the send side of the Viewer.Pipe client stream.
	SendStream() interface {
		// Send places the item onto the output stream.  Returns errors
		// encountered while sending, or if Send is called after Close or
		// the stream has been canceled.  Blocks if there is no buffer
		// space; will unblock when buffer space is available or after
		// the stream has been canceled.
		Send(item []byte) error
		// Close indicates to the server that no more items will be sent;
		// server Recv calls will receive io.EOF after all sent items.
		// This is an optional call - e.g. a client might call Close if it
		// needs to continue receiving items from the server after it's
		// done sending.  Returns errors encountered while closing, or if
		// Close is called after the stream has been canceled.  Like Send,
		// blocks if there is no buffer space available.
		Close() error
	}
}

// ViewerPipeCall represents the call returned from Viewer.Pipe.
type ViewerPipeCall interface {
	ViewerPipeClientStream
	// Finish performs the equivalent of SendStream().Close, then blocks until
	// the server is done, and returns the positional return values for the call.
	//
	// Finish returns immediately if the call has been canceled; depending on the
	// timing the output could either be an error signaling cancelation, or the
	// valid positional return values from the server.
	//
	// Calling Finish is mandatory for releasing stream resources, unless the call
	// has been canceled or any of the other methods return an error.  Finish should
	// be called at most once.
	Finish() (*vdl.Value, error)
}

type implViewerPipeCall struct {
	ipc.Call
}

func (c *implViewerPipeCall) SendStream() interface {
	Send(item []byte) error
	Close() error
} {
	return implViewerPipeCallSend{c}
}

type implViewerPipeCallSend struct {
	c *implViewerPipeCall
}

func (c implViewerPipeCallSend) Send(item []byte) error {
	return c.c.Send(item)
}
func (c implViewerPipeCallSend) Close() error {
	return c.c.CloseSend()
}
func (c *implViewerPipeCall) Finish() (o0 *vdl.Value, err error) {
	err = c.Call.Finish(&o0)
	return
}

// ViewerServerMethods is the interface a server writer
// implements for Viewer.
//
// Viewer allows clients to stream data to it and to request a
// particular viewer to format and display the data.
type ViewerServerMethods interface {
	// Pipe creates a bidirectional pipe between client and viewer
	// service, returns total number of bytes received by the service
	// after streaming ends
	Pipe(ViewerPipeContext) (*vdl.Value, error)
}

// ViewerServerStubMethods is the server interface containing
// Viewer methods, as expected by ipc.Server.
// The only difference between this interface and ViewerServerMethods
// is the streaming methods.
type ViewerServerStubMethods interface {
	// Pipe creates a bidirectional pipe between client and viewer
	// service, returns total number of bytes received by the service
	// after streaming ends
	Pipe(*ViewerPipeContextStub) (*vdl.Value, error)
}

// ViewerServerStub adds universal methods to ViewerServerStubMethods.
type ViewerServerStub interface {
	ViewerServerStubMethods
	// Describe the Viewer interfaces.
	Describe__() []ipc.InterfaceDesc
}

// ViewerServer returns a server stub for Viewer.
// It converts an implementation of ViewerServerMethods into
// an object that may be used by ipc.Server.
func ViewerServer(impl ViewerServerMethods) ViewerServerStub {
	stub := implViewerServerStub{
		impl: impl,
	}
	// Initialize GlobState; always check the stub itself first, to handle the
	// case where the user has the Glob method defined in their VDL source.
	if gs := ipc.NewGlobState(stub); gs != nil {
		stub.gs = gs
	} else if gs := ipc.NewGlobState(impl); gs != nil {
		stub.gs = gs
	}
	return stub
}

type implViewerServerStub struct {
	impl ViewerServerMethods
	gs   *ipc.GlobState
}

func (s implViewerServerStub) Pipe(ctx *ViewerPipeContextStub) (*vdl.Value, error) {
	return s.impl.Pipe(ctx)
}

func (s implViewerServerStub) Globber() *ipc.GlobState {
	return s.gs
}

func (s implViewerServerStub) Describe__() []ipc.InterfaceDesc {
	return []ipc.InterfaceDesc{ViewerDesc}
}

// ViewerDesc describes the Viewer interface.
var ViewerDesc ipc.InterfaceDesc = descViewer

// descViewer hides the desc to keep godoc clean.
var descViewer = ipc.InterfaceDesc{
	Name:    "Viewer",
	PkgPath: "p2b/vdl",
	Doc:     "// Viewer allows clients to stream data to it and to request a\n// particular viewer to format and display the data.",
	Methods: []ipc.MethodDesc{
		{
			Name: "Pipe",
			Doc:  "// Pipe creates a bidirectional pipe between client and viewer\n// service, returns total number of bytes received by the service\n// after streaming ends",
			OutArgs: []ipc.ArgDesc{
				{"", ``}, // *vdl.Value
			},
		},
	},
}

// ViewerPipeServerStream is the server stream for Viewer.Pipe.
type ViewerPipeServerStream interface {
	// RecvStream returns the receiver side of the Viewer.Pipe server stream.
	RecvStream() interface {
		// Advance stages an item so that it may be retrieved via Value.  Returns
		// true iff there is an item to retrieve.  Advance must be called before
		// Value is called.  May block if an item is not available.
		Advance() bool
		// Value returns the item that was staged by Advance.  May panic if Advance
		// returned false or was not called.  Never blocks.
		Value() []byte
		// Err returns any error encountered by Advance.  Never blocks.
		Err() error
	}
}

// ViewerPipeContext represents the context passed to Viewer.Pipe.
type ViewerPipeContext interface {
	ipc.ServerContext
	ViewerPipeServerStream
}

// ViewerPipeContextStub is a wrapper that converts ipc.ServerCall into
// a typesafe stub that implements ViewerPipeContext.
type ViewerPipeContextStub struct {
	ipc.ServerCall
	valRecv []byte
	errRecv error
}

// Init initializes ViewerPipeContextStub from ipc.ServerCall.
func (s *ViewerPipeContextStub) Init(call ipc.ServerCall) {
	s.ServerCall = call
}

// RecvStream returns the receiver side of the Viewer.Pipe server stream.
func (s *ViewerPipeContextStub) RecvStream() interface {
	Advance() bool
	Value() []byte
	Err() error
} {
	return implViewerPipeContextRecv{s}
}

type implViewerPipeContextRecv struct {
	s *ViewerPipeContextStub
}

func (s implViewerPipeContextRecv) Advance() bool {
	s.s.errRecv = s.s.Recv(&s.s.valRecv)
	return s.s.errRecv == nil
}
func (s implViewerPipeContextRecv) Value() []byte {
	return s.s.valRecv
}
func (s implViewerPipeContextRecv) Err() error {
	if s.s.errRecv == io.EOF {
		return nil
	}
	return s.s.errRecv
}
