~rbn/neinp

ref: 55b6eee1e78f053b260d845551ee71f4777448c6 neinp/message/flush.go -rw-r--r-- 1022 bytes
55b6eee1Ruben Schuller move to sr.ht and go modulize 1 year, 10 months 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 (
	"git.sr.ht/~rbn/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
}