~rbn/neinp

ref: 280ca11dc4f314d4bb506de2f219eb70dd959227 neinp/message/clunk.go -rw-r--r-- 1.0 KiB
280ca11dRuben Schuller update go.mod 1 year, 2 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
49
50
51
52
53
54
55
56
57
package message

import (
	"git.sr.ht/~rbn/neinp/basic"
	"git.sr.ht/~rbn/neinp/fid"
	"io"
)

/*TClunk requests to forget a fid.

The mapping on the server from fid to actual file should be removed,
not touching the actual file unless it was used OpenClose.

Regardless of the result of this call, the fid will not be valid anymore
and can be reused.

See also: http://man.cat-v.org/plan_9/5/clunk
*/
type TClunk struct {
	Fid fid.Fid
}

func (m *TClunk) encode(w io.Writer) (int64, error) {
	n, err := basic.Uint32Encode(w, uint32(m.Fid))
	if err != nil {
		return n, err
	}

	return n, nil
}

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

	m.Fid = fid.Fid(f)

	return n, err
}

/*RClunk signals a successful clunk.

After the fid is successfully clunked it can be reused.

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

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

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