-
Notifications
You must be signed in to change notification settings - Fork 8
/
stream.go
34 lines (31 loc) · 1.06 KB
/
stream.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
package stream
import (
"time"
)
// OpenOpts are optional arguments when opening a stream.
type OpenOpts struct {
// Encrypted indicates the stream MUST be encrypted.
// An error is returned if the stream cannot be encrypted.
Encrypted bool
// Reliable indicates the stream MUST be reliable / ordered.
// An error is returned if the stream cannot be reliable.
Reliable bool
}
// Stream is a stream-based data channel between two peers over a link.
type Stream interface {
// Read data from the stream.
Read(b []byte) (n int, err error)
// Write data to the stream.
Write(b []byte) (n int, err error)
// SetReadDeadline sets the read deadline as defined by
// A zero time value disables the deadline.
SetReadDeadline(t time.Time) error
// SetWriteDeadline sets the write deadline as defined by
// A zero time value disables the deadline.
SetWriteDeadline(t time.Time) error
// SetDeadline sets both read and write deadlines as defined by
// A zero time value disables the deadlines.
SetDeadline(t time.Time) error
// Close closes the stream.
Close() error
}