// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package interceptor

// Registry is a collector for interceptors.
type Registry struct {
	factories []Factory
}

// Add adds a new Interceptor to the registry.
func ( *Registry) ( Factory) {
	.factories = append(.factories, )
}

// Build constructs a single Interceptor from a InterceptorRegistry.
func ( *Registry) ( string) (Interceptor, error) {
	if len(.factories) == 0 {
		return &NoOp{}, nil
	}

	 := []Interceptor{}
	for ,  := range .factories {
		,  := .NewInterceptor()
		if  != nil {
			return nil, 
		}

		 = append(, )
	}

	return NewChain(), nil
}