package quic

import (
	
	
)

// readFromChunkSize is the size of the staging buffer ReadFrom copies through.
const readFromChunkSize = 64 * 1024

// ReadFrom implements [io.ReaderFrom]. It reads from r until EOF or error,
// writing to the stream in chunks. Data is copied into stream-owned storage
// before each chunk write returns.
func ( *SendStream) ( io.Reader) (int64, error) {
	var  int64
	 := make([]byte, readFromChunkSize)
	for {
		,  := .Read()
		if  > 0 {
			,  := .Write([:])
			 += int64()
			if  != nil {
				return , 
			}
		}
		if  == io.EOF {
			return , nil
		}
		if  != nil {
			return , 
		}
	}
}

// Writev writes the buffers in order. It returns the total number of bytes
// written and advances bufs to reflect exactly what was consumed, including a
// partially written element, so the caller can resume after a short write.
// The stream copies data into owned storage before Writev returns; the caller
// may reuse the underlying slices immediately.
//
// Writev does not hold the stream for the whole vector: another writer may
// interleave between elements. The delivered byte stream is identical to the
// equivalent sequence of Write calls.
//
// To send a [net.Buffers], call Writev directly: [net.Buffers] implements
// [io.WriterTo], which [io.Copy] prefers over [io.ReaderFrom], so
// io.Copy(stream, &bufs) degrades to one Write call per element.
func ( *SendStream) ( *net.Buffers) (int64, error) {
	var  int64
	var  error
	for ,  := range * {
		if len() == 0 {
			continue
		}
		var  int
		,  = .Write()
		 += int64()
		if  != nil {
			break
		}
	}
	 := 
	for  > 0 && len(*) > 0 {
		if  := int64(len((*)[0]));  >=  {
			 -= 
			* = (*)[1:]
			continue
		}
		(*)[0] = (*)[0][:]
		 = 0
	}
	if  > 0 && len(*) > 0 &&  == nil {
		 = io.ErrShortWrite
	}
	return , 
}