-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathreadablestream.go
More file actions
44 lines (34 loc) · 1.1 KB
/
Copy pathreadablestream.go
File metadata and controls
44 lines (34 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
package quic
import (
"time"
"github.com/pion/quic/internal/wrapper"
quic "github.com/quic-go/quic-go"
)
// StreamID is the ID of a quic stream.
type StreamID int64
// ReadableStream represents a unidirectional quic ReceiveStream.
type ReadableStream struct {
s *wrapper.ReadableStream
}
// ReadInto reads from the ReadableStream into the buffer.
func (s *ReadableStream) ReadInto(data []byte) (StreamReadResult, error) {
n, fin, err := s.s.ReadQuic(data)
return StreamReadResult{
Amount: n,
Finished: fin,
}, err
}
// StreamID returns the ID of the ReadableStream.
func (s *ReadableStream) StreamID() StreamID {
return StreamID(s.s.StreamID())
}
// SetReadDeadline sets the deadline for future Read calls. A zero value for t means Read will not time out.
func (s *ReadableStream) SetReadDeadline(t time.Time) error {
return s.s.SetReadDeadline(t)
}
// Detach detaches and returns the underlying quic-go ReceiveStream.
func (s *ReadableStream) Detach() *quic.ReceiveStream {
return s.s.Detach()
}