MCPcopy Create free account
hub / github.com/pion/dtls / DecodeCompressionMethods

Function DecodeCompressionMethods

pkg/protocol/compression_method.go:26–43  ·  view source on GitHub ↗

DecodeCompressionMethods the given compression methods.

(buf []byte)

Source from the content-addressed store, hash-verified

24
25// DecodeCompressionMethods the given compression methods.
26func DecodeCompressionMethods(buf []byte) ([]*CompressionMethod, error) {
27 if len(buf) < 1 {
28 return nil, errBufferTooSmall
29 }
30 compressionMethodsCount := int(buf[0])
31 c := []*CompressionMethod{}
32 for i := range compressionMethodsCount {
33 if len(buf) <= i+1 {
34 return nil, errBufferTooSmall
35 }
36 id := CompressionMethodID(buf[i+1])
37 if compressionMethod, ok := CompressionMethods()[id]; ok {
38 c = append(c, compressionMethod)
39 }
40 }
41
42 return c, nil
43}
44
45// EncodeCompressionMethods the given compression methods.
46func EncodeCompressionMethods(c []*CompressionMethod) []byte {

Callers 2

UnmarshalMethod · 0.92

Calls 2

CompressionMethodIDTypeAlias · 0.85
CompressionMethodsFunction · 0.85

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…