NewDecodingLayerParser creates a new DecodingLayerParser and adds in all of the given DecodingLayers with AddDecodingLayer. Each call to DecodeLayers will attempt to decode the given bytes first by treating them as a 'first'-type layer, then by using NextLayerType on subsequently decoded layers to
(first LayerType, decoders ...DecodingLayer)
| 220 | // NewDecodingLayerParser uses DecodingLayerMap container by |
| 221 | // default. |
| 222 | func NewDecodingLayerParser(first LayerType, decoders ...DecodingLayer) *DecodingLayerParser { |
| 223 | dlp := &DecodingLayerParser{first: first} |
| 224 | dlp.df = dlp // Cast this once to the interface |
| 225 | // default container |
| 226 | dlc := DecodingLayerContainer(DecodingLayerMap(make(map[LayerType]DecodingLayer))) |
| 227 | for _, d := range decoders { |
| 228 | dlc = dlc.Put(d) |
| 229 | } |
| 230 | |
| 231 | dlp.SetDecodingLayerContainer(dlc) |
| 232 | return dlp |
| 233 | } |
| 234 | |
| 235 | // SetDecodingLayerContainer specifies container with decoders. This |
| 236 | // call replaces all decoders already registered in given instance of |
searching dependent graphs…