| // 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. |
| // Source: sprinkler.vdl |
| |
| package sample |
| |
| import ( |
| // VDL system imports |
| "v.io/v23" |
| "v.io/v23/context" |
| "v.io/v23/rpc" |
| ) |
| |
| // SprinklerClientMethods is the client interface |
| // containing Sprinkler methods. |
| // |
| // Sprinkler allows clients to control the virtual sprinkler. |
| type SprinklerClientMethods interface { |
| // Status retrieves the Sprinkler's status (i.e., active, idle) |
| Status(*context.T, ...rpc.CallOpt) (string, error) |
| // Start causes the Sprinkler to emit water for the given duration (in seconds). |
| Start(ctx *context.T, duration uint16, opts ...rpc.CallOpt) error |
| // Stop causes the Sprinkler to cease watering. |
| Stop(*context.T, ...rpc.CallOpt) error |
| } |
| |
| // SprinklerClientStub adds universal methods to SprinklerClientMethods. |
| type SprinklerClientStub interface { |
| SprinklerClientMethods |
| rpc.UniversalServiceMethods |
| } |
| |
| // SprinklerClient returns a client stub for Sprinkler. |
| func SprinklerClient(name string) SprinklerClientStub { |
| return implSprinklerClientStub{name} |
| } |
| |
| type implSprinklerClientStub struct { |
| name string |
| } |
| |
| func (c implSprinklerClientStub) Status(ctx *context.T, opts ...rpc.CallOpt) (o0 string, err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "Status", nil, []interface{}{&o0}, opts...) |
| return |
| } |
| |
| func (c implSprinklerClientStub) Start(ctx *context.T, i0 uint16, opts ...rpc.CallOpt) (err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "Start", []interface{}{i0}, nil, opts...) |
| return |
| } |
| |
| func (c implSprinklerClientStub) Stop(ctx *context.T, opts ...rpc.CallOpt) (err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "Stop", nil, nil, opts...) |
| return |
| } |
| |
| // SprinklerServerMethods is the interface a server writer |
| // implements for Sprinkler. |
| // |
| // Sprinkler allows clients to control the virtual sprinkler. |
| type SprinklerServerMethods interface { |
| // Status retrieves the Sprinkler's status (i.e., active, idle) |
| Status(*context.T, rpc.ServerCall) (string, error) |
| // Start causes the Sprinkler to emit water for the given duration (in seconds). |
| Start(ctx *context.T, call rpc.ServerCall, duration uint16) error |
| // Stop causes the Sprinkler to cease watering. |
| Stop(*context.T, rpc.ServerCall) error |
| } |
| |
| // SprinklerServerStubMethods is the server interface containing |
| // Sprinkler methods, as expected by rpc.Server. |
| // There is no difference between this interface and SprinklerServerMethods |
| // since there are no streaming methods. |
| type SprinklerServerStubMethods SprinklerServerMethods |
| |
| // SprinklerServerStub adds universal methods to SprinklerServerStubMethods. |
| type SprinklerServerStub interface { |
| SprinklerServerStubMethods |
| // Describe the Sprinkler interfaces. |
| Describe__() []rpc.InterfaceDesc |
| } |
| |
| // SprinklerServer returns a server stub for Sprinkler. |
| // It converts an implementation of SprinklerServerMethods into |
| // an object that may be used by rpc.Server. |
| func SprinklerServer(impl SprinklerServerMethods) SprinklerServerStub { |
| stub := implSprinklerServerStub{ |
| 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 := rpc.NewGlobState(stub); gs != nil { |
| stub.gs = gs |
| } else if gs := rpc.NewGlobState(impl); gs != nil { |
| stub.gs = gs |
| } |
| return stub |
| } |
| |
| type implSprinklerServerStub struct { |
| impl SprinklerServerMethods |
| gs *rpc.GlobState |
| } |
| |
| func (s implSprinklerServerStub) Status(ctx *context.T, call rpc.ServerCall) (string, error) { |
| return s.impl.Status(ctx, call) |
| } |
| |
| func (s implSprinklerServerStub) Start(ctx *context.T, call rpc.ServerCall, i0 uint16) error { |
| return s.impl.Start(ctx, call, i0) |
| } |
| |
| func (s implSprinklerServerStub) Stop(ctx *context.T, call rpc.ServerCall) error { |
| return s.impl.Stop(ctx, call) |
| } |
| |
| func (s implSprinklerServerStub) Globber() *rpc.GlobState { |
| return s.gs |
| } |
| |
| func (s implSprinklerServerStub) Describe__() []rpc.InterfaceDesc { |
| return []rpc.InterfaceDesc{SprinklerDesc} |
| } |
| |
| // SprinklerDesc describes the Sprinkler interface. |
| var SprinklerDesc rpc.InterfaceDesc = descSprinkler |
| |
| // descSprinkler hides the desc to keep godoc clean. |
| var descSprinkler = rpc.InterfaceDesc{ |
| Name: "Sprinkler", |
| PkgPath: "v.io/x/browser/sample", |
| Doc: "// Sprinkler allows clients to control the virtual sprinkler.", |
| Methods: []rpc.MethodDesc{ |
| { |
| Name: "Status", |
| Doc: "// Status retrieves the Sprinkler's status (i.e., active, idle)", |
| OutArgs: []rpc.ArgDesc{ |
| {"", ``}, // string |
| }, |
| }, |
| { |
| Name: "Start", |
| Doc: "// Start causes the Sprinkler to emit water for the given duration (in seconds).", |
| InArgs: []rpc.ArgDesc{ |
| {"duration", ``}, // uint16 |
| }, |
| }, |
| { |
| Name: "Stop", |
| Doc: "// Stop causes the Sprinkler to cease watering.", |
| }, |
| }, |
| } |