extenstion.go 878 B

1234567891011121314151617181920212223242526272829
  1. package wsutil
  2. // RecvExtension is an interface for clearing fragment header RSV bits.
  3. type RecvExtension interface {
  4. BitsRecv(seq int, rsv byte) (byte, error)
  5. }
  6. // RecvExtensionFunc is an adapter to allow the use of ordinary functions as
  7. // RecvExtension.
  8. type RecvExtensionFunc func(int, byte) (byte, error)
  9. // BitsRecv implements RecvExtension.
  10. func (fn RecvExtensionFunc) BitsRecv(seq int, rsv byte) (byte, error) {
  11. return fn(seq, rsv)
  12. }
  13. // SendExtension is an interface for setting fragment header RSV bits.
  14. type SendExtension interface {
  15. BitsSend(seq int, rsv byte) (byte, error)
  16. }
  17. // SendExtensionFunc is an adapter to allow the use of ordinary functions as
  18. // SendExtension.
  19. type SendExtensionFunc func(int, byte) (byte, error)
  20. // BitsSend implements SendExtension.
  21. func (fn SendExtensionFunc) BitsSend(seq int, rsv byte) (byte, error) {
  22. return fn(seq, rsv)
  23. }