Documentation ¶
Index ¶
- Constants
- Variables
- func NewBoundaryString(src io.Reader, search string) io.Reader
- func NewBoundaryStringCloser(src io.ReadCloser, search string) io.ReadCloser
- func ReadUntil(r io.Reader, b byte, buf []byte) (int, bool, error)
- func ReadUntilAny(r io.Reader, ends []byte, buf []byte) (int, bool, error)
- type ErrorType
- type StreamError
Constants ¶
const ( // ErrBufferTooSmall indicates that a Read call was made with a // buffer too small for some guarantee to be held. ErrBufferTooSmall = ErrorType(iota + 1) )
Variables ¶
var DebugStackTrace bool
DebugStackTrace indicates whether or not errors from this library will yield a stack trace. This is not thread-safe. It is intended to be set at start time, generally by test code. It should not be modified once streamtools are being used.
Functions ¶
func NewBoundaryString ¶ added in v0.0.4
NewBoundaryAtomicString returns a reader that will do its best to return the search string atomically in a Read call.
An example use for this is filtering an HTTP POST body or response for passwords. Create a NewBoundaryString with a search string of "password", and it becomes safe to .Read from the reader and simply check to see if the .Read value is == "password".
If the buffer is not large enough to contain the search string, it will still be chunked, but of course the search string will not be in one .Read call.
func NewBoundaryStringCloser ¶ added in v0.0.4
func NewBoundaryStringCloser(src io.ReadCloser, search string) io.ReadCloser
NewBoundaryStringCloser is the same as NewBoundaryString, except it returns something that can also be closed.
func ReadUntil ¶ added in v0.0.2
ReadUntil will read the given reader until the given byte is encountered, and put the values into the buffer. The int will return the number of bytes written into the buffer. The boolean will be true if the read completed, and false if there is more to read yet. error will be returned from the underlying reader, if any.
The checked byte will be consumed, but nothing else will be.
func ReadUntilAny ¶ added in v0.0.2
ReadUntilAny will read the given reader until one of the given bytes is encountered, and put the values into the buffer. The int will return the number of bytes written into the buffer. The boolean will be true if the read completed, and false if there is more to read yet. error will be returned from the underlying reader, if any.
The checked byte will be consumed, but nothing else will be.
If no ends bytes are passed, this degenerates into a call to io.ReadFull, except ErrUnexpectedEOF will be ignored because the caller is not trying to guarantee that there are enough bytes to fill the buffer.
Types ¶
type ErrorType ¶
type ErrorType int
ErrorType is a constant that indicates the type of error that has occurred.
type StreamError ¶
StreamError is the type of error returned by everything in this package. It supports having an ErrorType that can be examined without having to pull apart the inner error, and an optional stack trace.
func (StreamError) Error ¶
func (se StreamError) Error() string
Error implements the error interface.
func (StreamError) Unwrap ¶
func (se StreamError) Unwrap() []error
Unwrap implements the error unwrapping protocol.
Directories ¶
Path | Synopsis |
---|---|
Package advstreamtools provides access to more generic streaming tools, based on the io.Reader and io.Writer interface, but generalized beyond byte streams to streams of anything.
|
Package advstreamtools provides access to more generic streaming tools, based on the io.Reader and io.Writer interface, but generalized beyond byte streams to streams of anything. |