github.com/simonmittag/ws@v1.1.0-rc.5.0.20210419231947-82b846128245/wsutil/extenstion.go (about)

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