github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/endpoint.go (about) 1 package gomavlib 2 3 import ( 4 "io" 5 ) 6 7 // EndpointConf is the interface implemented by all endpoint configurations. 8 type EndpointConf interface { 9 init(*Node) (Endpoint, error) 10 } 11 12 // Endpoint is an endpoint, which can create Channels. 13 type Endpoint interface { 14 // Conf returns the configuration used to initialize the endpoint 15 Conf() EndpointConf 16 isEndpoint() 17 } 18 19 // a endpoint must also implement one of the following: 20 // - endpointChannelSingle 21 // - endpointChannelProvider 22 23 // endpointChannelSingle is an endpoint that provides a single channel. 24 // Read() must not return any error unless Close() is called. 25 type endpointChannelSingle interface { 26 Endpoint 27 label() string 28 io.ReadWriteCloser 29 } 30 31 // endpointChannelProvider is an endpoint that provides multiple channels. 32 type endpointChannelProvider interface { 33 Endpoint 34 close() 35 oneChannelAtAtime() bool 36 provide() (string, io.ReadWriteCloser, error) 37 }