forked from vanadium-archive/go.v23
/
invalid_types.go
55 lines (42 loc) · 1.29 KB
/
invalid_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// 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.
package syncbase
// invalidStream is a Stream for which all methods return errors.
type invalidStream struct {
err error // returned by all methods
}
var _ Stream = (*invalidStream)(nil)
// Advance implements the Stream interface.
func (_ *invalidStream) Advance() bool {
return false
}
// Err implements the Stream interface.
func (s *invalidStream) Err() error {
return s.err
}
// Cancel implements the Stream interface.
func (_ *invalidStream) Cancel() {
}
// invalidScanStream is a ScanStream for which all methods return errors.
type invalidScanStream struct {
invalidStream
}
var _ ScanStream = (*invalidScanStream)(nil)
// Key implements the ScanStream interface.
func (s *invalidScanStream) Key() string {
panic(s.err)
}
// Value implements the ScanStream interface.
func (s *invalidScanStream) Value(value interface{}) error {
panic(s.err)
}
// invalidWatchStream is a WatchStream for which all methods return errors.
type invalidWatchStream struct {
invalidStream
}
var _ WatchStream = (*invalidWatchStream)(nil)
// Change implements the WatchStream interface.
func (s *invalidWatchStream) Change() WatchChange {
panic(s.err)
}