~rbn/neinp

ref: f0b91981560c6d7f112692b0479d8d28cc062ba7 neinp/message/flush.go -rw-r--r-- 1.0 KiB
f0b91981Ruben Schuller add build badge 2 years ago
                                                                                
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
package message // import "go.rbn.im/neinp/message"

import (
	"go.rbn.im/neinp/basic"
	"io"
)

/*TFlush signals the server that it should abort processing a message.

Instances of Server directly handle these message type by running the cancel function
of the context for the message which should be aborted. It is here for usage in
client implementations.

Unlike the real world, flushing never fails.

See also: http://man.cat-v.org/inferno/5/flush
*/
type TFlush struct {
	Oldtag uint16
}

func (m *TFlush) encode(w io.Writer) (int64, error) {
	return basic.Uint16Encode(w, m.Oldtag)
}

func (m *TFlush) decode(r io.Reader) (int64, error) {
	oldtag, n, err := basic.Uint16Decode(r)
	if err != nil {
		return n, err
	}

	m.Oldtag = oldtag
	return n, err
}

/*RFlush is the answer to a TFlush and signals that the flush has finished.

See also: http://man.cat-v.org/plan_9/5/flush */
type RFlush struct {
}

func (m *RFlush) encode(w io.Writer) (int64, error) {
	return 0, nil
}

func (m *RFlush) decode(r io.Reader) (int64, error) {
	return 0, nil
}