github.com/bluenviron/gomavlib/v3@v3.0.0/endpoint_custom.go (about)

     1  package gomavlib
     2  
     3  import (
     4  	"io"
     5  )
     6  
     7  // EndpointCustom sets up a endpoint that works with a custom interface
     8  // that provides the Read(), Write() and Close() functions.
     9  type EndpointCustom struct {
    10  	// the struct or interface implementing Read(), Write() and Close()
    11  	ReadWriteCloser io.ReadWriteCloser
    12  }
    13  
    14  type endpointCustom struct {
    15  	conf EndpointCustom
    16  	io.ReadWriteCloser
    17  }
    18  
    19  func (conf EndpointCustom) init(_ *Node) (Endpoint, error) {
    20  	t := &endpointCustom{
    21  		conf:            conf,
    22  		ReadWriteCloser: conf.ReadWriteCloser,
    23  	}
    24  	return t, nil
    25  }
    26  
    27  func (t *endpointCustom) isEndpoint() {}
    28  
    29  func (t *endpointCustom) Conf() EndpointConf {
    30  	return t.conf
    31  }
    32  
    33  func (t *endpointCustom) label() string {
    34  	return "custom"
    35  }