mirror of
https://github.com/aler9/gortsplib
synced 2025-10-13 02:43:53 +08:00
allow writing primitives to static buffers
This commit is contained in:
@@ -35,11 +35,16 @@ func (b *body) read(header Header, rb *bufio.Reader) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b body) write(w io.Writer) error {
|
||||
if len(b) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := w.Write(b)
|
||||
return err
|
||||
func (b body) writeSize() int {
|
||||
return len(b)
|
||||
}
|
||||
|
||||
func (b body) writeTo(buf []byte) int {
|
||||
return copy(buf, b)
|
||||
}
|
||||
|
||||
func (b body) write() []byte {
|
||||
buf := make([]byte, b.writeSize())
|
||||
b.writeTo(buf)
|
||||
return buf
|
||||
}
|
||||
|
Reference in New Issue
Block a user