good morning!!!!

Skip to content
Snippets Groups Projects
Commit d85d0b3f authored by Garet Halliday's avatar Garet Halliday
Browse files

buffer to buffer copy

parent bf8a04e3
No related branches found
No related tags found
No related merge requests found
package fed
import "io"
type Packet interface {
Type() Type
Length() int
......@@ -26,12 +28,19 @@ func (T PendingPacket) Length() int {
}
func (T PendingPacket) WriteTo(encoder *Encoder) error {
// TODO(garet) this should be better
b, err := T.Decoder.Remaining()
if err != nil {
return err
count := T.Decoder.len - T.Decoder.pos
limited := io.LimitedReader{
R: &T.Decoder.Reader,
N: int64(count),
}
for limited.N > 0 {
if _, err := encoder.Writer.ReadFrom(&limited); err != nil {
return err
}
}
return encoder.Bytes(b)
T.Decoder.pos += count
encoder.pos += count
return nil
}
var _ Packet = PendingPacket{}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment