package sideband

import (
	

	
)
Muxer multiplex the packfile along with the progress messages and the error information. The multiplex is perform using pktline format.
type Muxer struct {
	max int
	e   *pktline.Encoder
}

const chLen = 1
NewMuxer returns a new Muxer for the given t that writes on w. If t is equal to `Sideband` the max pack size is set to MaxPackedSize, in any other value is given, max pack is set to MaxPackedSize64k, that is the maximum length of a line in pktline format.
func ( Type,  io.Writer) *Muxer {
	 := MaxPackedSize64k
	if  == Sideband {
		 = MaxPackedSize
	}

	return &Muxer{
		max:  - chLen,
		e:   pktline.NewEncoder(),
	}
}
Write writes p in the PackData channel
func ( *Muxer) ( []byte) (int, error) {
	return .WriteChannel(PackData, )
}
WriteChannel writes p in the given channel. This method can be used with any channel, but is recommend use it only for the ProgressMessage and ErrorMessage channels and use Write for the PackData channel
func ( *Muxer) ( Channel,  []byte) (int, error) {
	 := 0
	 := len()
	for  <  {
		,  := .doWrite(, [:])
		 += 

		if  != nil {
			return , 
		}
	}

	return , nil
}

func ( *Muxer) ( Channel,  []byte) (int, error) {
	 := len()
	if  > .max {
		 = .max
	}

	return , .e.Encode(.WithPayload([:]))