Documentation ¶
Index ¶
- Constants
- func ReportStatus(enc *Encoder, status *packp.ReportStatus)
- func WithSideband64kDemuxer(scn *Scanner)
- func WithSideband64kMuxer(enc *Encoder)
- func WithSidebandDemuxer(scn *Scanner)
- func WithSidebandMuxer(enc *Encoder)
- type Builder
- type EncodeSideband
- type Encoder
- func (enc *Encoder) Encode(b []byte) (err error)
- func (enc *Encoder) EncodeString(s string) (err error)
- func (enc *Encoder) Flush()
- func (enc *Encoder) SidebandCapability() SidebandCapability
- func (enc *Encoder) WithSidebandCapability(cap SidebandCapability) *Encoder
- func (enc *Encoder) Write(d []byte) (n int, err error)
- func (enc *Encoder) WriteString(s string) (n int, err error)
- type EncoderOption
- type ScanSideband
- type Scanner
- type ScannerOption
- type SidebandCapability
- type SidebandChannel
- type SidebandEncoder
- func (enc *SidebandEncoder) Data(c SidebandChannel, b []byte) (err error)
- func (enc *SidebandEncoder) Encode(c SidebandChannel, b []byte) (err error)
- func (enc *SidebandEncoder) EncodeError(s string) error
- func (enc *SidebandEncoder) EncodePackfile(b []byte) error
- func (enc *SidebandEncoder) EncodeProgress(s string) error
- func (enc *SidebandEncoder) EncodeString(c SidebandChannel, s string) error
- func (enc *SidebandEncoder) Flush() error
- func (enc *SidebandEncoder) Write(d []byte) (n int, err error)
- func (enc *SidebandEncoder) WriteString(s string) (n int, err error)
- type SidebandScanner
- func (scn *SidebandScanner) Bytes() []byte
- func (scn *SidebandScanner) Err() error
- func (scn *SidebandScanner) ErrorText() string
- func (scn *SidebandScanner) Packfile() []byte
- func (scn *SidebandScanner) ProgressText() string
- func (scn *SidebandScanner) Scan() bool
- func (scn *SidebandScanner) Text() string
Constants ¶
const ( ErrSidebandNotImplemented strErr = "sideband is not implemented" ErrSidebandChannelInvalid strErr = "sideband channel is invalid" ErrPktlineTooLong strErr = "pktline is too long to encode" ErrScanTooShort strErr = "pktline scan was too short" ErrScanInvalidLineLength strErr = "pktline scan line length is invalid" )
errors we handle
const MaxLength = 65516 // the data portion
MaxLength is The maximum length of a pkt-line's data component is 65516 bytes. Implementations MUST NOT send pkt-line whose length exceeds 65520 (65516 bytes of payload + 4 bytes of length data).
Variables ¶
This section is empty.
Functions ¶
func ReportStatus ¶
func ReportStatus(enc *Encoder, status *packp.ReportStatus)
ReportStatus returns the unpacked status from a report status it returns a sideband aware muxed value if necessary.
func WithSideband64kDemuxer ¶
func WithSideband64kDemuxer(scn *Scanner)
WithSideband64kDemuxer adds the Sideband64k demuxer to the scanner that newer clients can use
func WithSideband64kMuxer ¶
func WithSideband64kMuxer(enc *Encoder)
WithSideband64kMuxer adds the Sideband64k muxer to the encoder that newer clients can use
func WithSidebandDemuxer ¶
func WithSidebandDemuxer(scn *Scanner)
WithSidebandDemuxer adds the Sideband demuxer to the scanner that older clients can use
func WithSidebandMuxer ¶
func WithSidebandMuxer(enc *Encoder)
WithSidebandMuxer adds the Sideband muxer to the encoder that older clients can use
Types ¶
type Builder ¶
Builder wraps the standard library string builder and is a way to build encoded messages that can be sent as sideband data
func NewBuilder ¶
func NewBuilder() *Builder
NewBuilder returns a new builder this doesn't require the use of Encode or EncodeString to init the builder
func (*Builder) EncodeString ¶
EncodeString encodes the string s to the builder
func (*Builder) FlushString ¶
FlushString returns the fully built string with a trailing flush encoded.
type EncodeSideband ¶
type Encoder ¶
type Encoder struct { Sideband EncodeSideband // contains filtered or unexported fields }
Encoder is the underlining structure to encoding data to the added writer
func NewEncoder ¶
func NewEncoder(w io.Writer, opts ...EncoderOption) *Encoder
NewEncoder returns an encoder that will encode packets directly to the underlining writer
func (*Encoder) Encode ¶
Encode encodes bytes to the underlining writer. If a sideband is initiated, then the bytes will be encoded as a sideband mux'd packet line
func (*Encoder) EncodeString ¶
EncodeString encodes a string in the pkline format to the underlining writer. If a sideband is used then the string will be muxed as sideband or sidebadn64k
func (*Encoder) SidebandCapability ¶
func (enc *Encoder) SidebandCapability() SidebandCapability
SidebandCapability returns if the pktline encoder has any sideband capabilities initiated.
func (*Encoder) WithSidebandCapability ¶
func (enc *Encoder) WithSidebandCapability(cap SidebandCapability) *Encoder
WithSidebandCapability takes a sideband value and sets up the sideband encoding if the value is Sideband or Sideband64k. If the value is empty then no side-band is used. Calls to Sideband encoding will result in an error
type EncoderOption ¶
type EncoderOption func(*Encoder)
EncoderOption are functional options for encoding
func WithSidebandSkip ¶
func WithSidebandSkip(optFn EncoderOption, ok bool) EncoderOption
WithSidebandSkip allows for you to wrap the Sideband option with a skip option. That is if the client doesn't offer a sideband capability then the sideband information will be skipped. Otherwise there will be an error that there is no sideband information being written to the encoder.
type ScanSideband ¶
type Scanner ¶
type Scanner struct { Sideband ScanSideband // contains filtered or unexported fields }
Scanner is the object that allows scanning of pktline data
func NewScanner ¶
func NewScanner(r io.Reader, opts ...ScannerOption) *Scanner
NewScanner returns a scanner object that takes functional options
type ScannerOption ¶
type ScannerOption func(*Scanner)
ScannerOption are functional options for scanning pktline data
func WithWriter ¶
func WithWriter(w io.Writer) ScannerOption
WithWriter adds a writer that the scanner can write it's output to.
type SidebandCapability ¶
type SidebandCapability int
const ( SidebandNone SidebandCapability = 0 Sideband SidebandCapability = 1 Sideband64k SidebandCapability = 64 )
type SidebandChannel ¶
type SidebandChannel byte
const ( SidebandPackfile SidebandChannel = 0x1 SidebandProgress SidebandChannel = 0x2 SidebandError SidebandChannel = 0x3 )
type SidebandEncoder ¶
type SidebandEncoder struct {
// contains filtered or unexported fields
}
func (*SidebandEncoder) Data ¶
func (enc *SidebandEncoder) Data(c SidebandChannel, b []byte) (err error)
func (*SidebandEncoder) Encode ¶
func (enc *SidebandEncoder) Encode(c SidebandChannel, b []byte) (err error)
Encode takes a byte slice to encode for the following: If 'side-band' or 'side-band-64k' capabilities have been specified by the client, the server will send the packfile data multiplexed.
Each packet starting with the packet-line length of the amount of data that follows, followed by a single byte specifying the sideband the following data is coming in on.
func (*SidebandEncoder) EncodeError ¶
func (enc *SidebandEncoder) EncodeError(s string) error
EncodeError is a convenience method for EncodeString(Error, s)
func (*SidebandEncoder) EncodePackfile ¶
func (enc *SidebandEncoder) EncodePackfile(b []byte) error
EncodePackfile is a convenience method for Encode(Packfile, b)
func (*SidebandEncoder) EncodeProgress ¶
func (enc *SidebandEncoder) EncodeProgress(s string) error
EncodeProgress is a convenience method for EncodeString(Progress, s)
func (*SidebandEncoder) EncodeString ¶
func (enc *SidebandEncoder) EncodeString(c SidebandChannel, s string) error
EncodeString takes a string to encode for the following: If 'side-band' or 'side-band-64k' capabilities have been specified by the client, the server will send the packfile data multiplexed.
Each packet starting with the packet-line length of the amount of data that follows, followed by a single byte specifying the sideband the following data is coming in on.
func (*SidebandEncoder) Flush ¶
func (enc *SidebandEncoder) Flush() error
Flush sends 0000 to the underlining writer
func (*SidebandEncoder) Write ¶
func (enc *SidebandEncoder) Write(d []byte) (n int, err error)
Write is a pass-through method. All bytes should be previously encoded
func (*SidebandEncoder) WriteString ¶
func (enc *SidebandEncoder) WriteString(s string) (n int, err error)
WriteString is a pass-through convenience method for a string to be passed to the underlining writer. No encoding is happening
type SidebandScanner ¶
type SidebandScanner struct {
// contains filtered or unexported fields
}
func (*SidebandScanner) Bytes ¶
func (scn *SidebandScanner) Bytes() []byte
func (*SidebandScanner) Err ¶
func (scn *SidebandScanner) Err() error
func (*SidebandScanner) ErrorText ¶
func (scn *SidebandScanner) ErrorText() string
func (*SidebandScanner) Packfile ¶
func (scn *SidebandScanner) Packfile() []byte
func (*SidebandScanner) ProgressText ¶
func (scn *SidebandScanner) ProgressText() string
func (*SidebandScanner) Scan ¶
func (scn *SidebandScanner) Scan() bool
func (*SidebandScanner) Text ¶
func (scn *SidebandScanner) Text() string