package multistream

Import Path
	github.com/multiformats/go-multistream (on go.dev)

Dependency Relation
	imports 9 packages, and imported by 5 packages

Involved Source Files client.go lazyClient.go Package multistream implements a simple stream router for the multistream-select protocoli. The protocol is defined at https://github.com/multiformats/multistream-select
Package-Level Type Names (total 7)
/* sort by: | */
Type Parameters: T: StringLike ErrNotSupported is the error returned when the muxer doesn't support the protocols tried for the handshake. Slice of protocols that were not supported by the muxer ( ErrNotSupported[T]) Error() string ( ErrNotSupported[T]) Is(target error) bool ErrNotSupported : error
Type Parameters: T: StringLike Actual T Expected T ( ErrUnrecognizedResponse[T]) Error() string ErrUnrecognizedResponse : error
Type Parameters: T: StringLike Handler is a wrapper to HandlerFunc which attaches a name (protocol) and a match function which can optionally be used to select a handler by other means than the name. AddName T Handle HandlerFunc[T] MatchFunc func(T) bool
Type Parameters: T: StringLike HandlerFunc is a user-provided function used by the MultistreamMuxer to handle a protocol/stream. func (*MultistreamMuxer)[T].Negotiate(rwc io.ReadWriteCloser) (proto T, handler HandlerFunc[T], err error) func (*MultistreamMuxer)[T].AddHandler(protocol T, handler HandlerFunc[T]) func (*MultistreamMuxer)[T].AddHandlerWithFunc(protocol T, match func(T) bool, handler HandlerFunc[T])
LazyConn is the connection type returned by the lazy negotiation functions. ( LazyConn) Close() error Flush flushes the lazy negotiation, if any. ( LazyConn) Read(p []byte) (n int, err error) ( LazyConn) Write([]byte) (int, error) LazyConn : github.com/apache/thrift/lib/go/thrift.Flusher LazyConn : github.com/miekg/dns.Writer LazyConn : github.com/pion/stun.Connection LazyConn : github.com/pion/stun/v3.Connection LazyConn : github.com/prometheus/common/expfmt.Closer LazyConn : internal/bisect.Writer LazyConn : io.Closer LazyConn : io.ReadCloser LazyConn : io.Reader LazyConn : io.ReadWriteCloser LazyConn : io.ReadWriter LazyConn : io.WriteCloser LazyConn : io.Writer func NewMSSelect[T](c io.ReadWriteCloser, proto T) LazyConn func NewMultistream[T](c io.ReadWriteCloser, proto T) LazyConn
Type Parameters: T: StringLike MultistreamMuxer is a muxer for multistream. Depending on the stream protocol tag it will select the right handler and hand the stream off to it. AddHandler attaches a new protocol handler to the muxer. AddHandlerWithFunc attaches a new protocol handler to the muxer with a match. If the match function returns true for a given protocol tag, the protocol will be selected even if the handler name and protocol tags are different. Handle performs protocol negotiation on a ReadWriteCloser (i.e. a connection). It will find a matching handler for the incoming protocol and pass the ReadWriteCloser to it. Negotiate performs protocol selection and returns the protocol name and the matching handler function for it (or an error). Protocols returns the list of handler-names added to this this muxer. RemoveHandler removes the handler with the given name from the muxer. func NewMultistreamMuxer[T]() *MultistreamMuxer[T]
StringLike is an interface that supports all types with underlying type string
Package-Level Functions (total 7)
Type Parameters: T: StringLike NewMSSelect returns a new Multistream which is able to perform protocol selection with a MultistreamMuxer.
Type Parameters: T: StringLike NewMultistream returns a multistream for the given protocol. This will not perform any protocol selection. If you are using a MultistreamMuxer, use NewMSSelect.
Type Parameters: T: StringLike NewMultistreamMuxer creates a muxer.
Type Parameters: T: StringLike ReadNextToken extracts a token from a Reader. It is used during protocol negotiation and returns a string.
ReadNextTokenBytes extracts a token from a Reader. It is used during protocol negotiation and returns a byte slice.
Type Parameters: T: StringLike SelectOneOf will perform handshakes with the protocols on the given slice until it finds one which is supported by the muxer.
Type Parameters: T: StringLike SelectProtoOrFail performs the initial multistream handshake to inform the muxer of the protocol that will be used to communicate on this ReadWriteCloser. It returns an error if, for example, the muxer does not know how to handle this protocol.
Package-Level Variables (total 3)
ErrIncorrectVersion is an error reported when the muxer protocol negotiation fails because of a ProtocolID mismatch.
ErrNoProtocols is the error returned when the no protocols have been specified.
ErrTooLarge is an error to signal that an incoming message was too large
Package-Level Constants (only one)
ProtocolID identifies the multistream protocol itself and makes sure the multistream muxers on both sides of a channel can work with each other.