-
Notifications
You must be signed in to change notification settings - Fork 0
/
extenstion.go
31 lines (24 loc) · 898 Bytes
/
extenstion.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
package wsutil
import "github.com/marks12/ws"
// RecvExtension is an interface for clearing fragment header RSV bits.
type RecvExtension interface {
UnsetBits(ws.Header) (ws.Header, error)
}
// RecvExtensionFunc is an adapter to allow the use of ordinary functions as
// RecvExtension.
type RecvExtensionFunc func(ws.Header) (ws.Header, error)
// BitsRecv implements RecvExtension.
func (fn RecvExtensionFunc) UnsetBits(h ws.Header) (ws.Header, error) {
return fn(h)
}
// SendExtension is an interface for setting fragment header RSV bits.
type SendExtension interface {
SetBits(ws.Header) (ws.Header, error)
}
// SendExtensionFunc is an adapter to allow the use of ordinary functions as
// SendExtension.
type SendExtensionFunc func(ws.Header) (ws.Header, error)
// BitsSend implements SendExtension.
func (fn SendExtensionFunc) SetBits(h ws.Header) (ws.Header, error) {
return fn(h)
}