github.com/la5nta/wl2k-go@v0.11.8/transport/interfaces.go (about) 1 // Copyright 2016 Martin Hebnes Pedersen (LA5NTA). All rights reserved. 2 // Use of this source code is governed by the MIT-license that can be 3 // found in the LICENSE file. 4 5 package transport 6 7 import ( 8 "context" 9 "net" 10 ) 11 12 type Flusher interface { 13 // Flush flushes the transmit buffers of the underlying modem. 14 Flush() error 15 } 16 17 type TxBuffer interface { 18 // TransmitBufferLen returns the number of bytes in the out buffer queue. 19 TxBufferLen() int 20 } 21 22 type Robust interface { 23 // Enables/disables robust mode. 24 SetRobust(r bool) error 25 } 26 27 // A BusyChannelChecker is a generic busy detector for a physical transmission medium. 28 type BusyChannelChecker interface { 29 // Returns true if the channel is not clear 30 Busy() bool 31 } 32 33 type PTTController interface { 34 SetPTT(on bool) error 35 } 36 37 // Dialer is implemented by transports that supports dialing a transport.URL. 38 type Dialer interface { 39 DialURL(url *URL) (net.Conn, error) 40 } 41 42 // ContextDialer is implemented by transports that supports dialing with cancellation. 43 type ContextDialer interface { 44 // DiaulURLContext dials a connection. 45 // 46 // If the given context is cancelled before the connection is made, the operation is aborted and an error returned. 47 // Once successfully connected, any expiration of the context will not affect the connection. 48 DialURLContext(ctx context.Context, url *URL) (net.Conn, error) 49 }