extenstion.go 897 B

12345678910111213141516171819202122232425262728293031
  1. package wsutil
  2. import "github.com/gobwas/ws"
  3. // RecvExtension is an interface for clearing fragment header RSV bits.
  4. type RecvExtension interface {
  5. UnsetBits(ws.Header) (ws.Header, error)
  6. }
  7. // RecvExtensionFunc is an adapter to allow the use of ordinary functions as
  8. // RecvExtension.
  9. type RecvExtensionFunc func(ws.Header) (ws.Header, error)
  10. // BitsRecv implements RecvExtension.
  11. func (fn RecvExtensionFunc) UnsetBits(h ws.Header) (ws.Header, error) {
  12. return fn(h)
  13. }
  14. // SendExtension is an interface for setting fragment header RSV bits.
  15. type SendExtension interface {
  16. SetBits(ws.Header) (ws.Header, error)
  17. }
  18. // SendExtensionFunc is an adapter to allow the use of ordinary functions as
  19. // SendExtension.
  20. type SendExtensionFunc func(ws.Header) (ws.Header, error)
  21. // BitsSend implements SendExtension.
  22. func (fn SendExtensionFunc) SetBits(h ws.Header) (ws.Header, error) {
  23. return fn(h)
  24. }