Decode decodes the given data using the decoder registered with the layer type.
(data []byte, c PacketBuilder)
| 85 | // Decode decodes the given data using the decoder registered with the layer |
| 86 | // type. |
| 87 | func (t LayerType) Decode(data []byte, c PacketBuilder) error { |
| 88 | var d Decoder |
| 89 | if 0 <= int(t) && int(t) < maxLayerType { |
| 90 | d = ltMeta[int(t)].Decoder |
| 91 | } else { |
| 92 | d = ltMetaMap[t].Decoder |
| 93 | } |
| 94 | if d != nil { |
| 95 | return d.Decode(data, c) |
| 96 | } |
| 97 | return fmt.Errorf("Layer type %v has no associated decoder", t) |
| 98 | } |
| 99 | |
| 100 | // String returns the string associated with this layer type. |
| 101 | func (t LayerType) String() (s string) { |