// RegisterEncoder updates a simple map of multicodec indicator number to ipld.Encoder function.
// The encoder functions registered can be subsequently looked up using LookupEncoder.
//
// Packages which implement an IPLD codec and have a multicodec number reserved in
// https://github.com/multiformats/multicodec/blob/master/table.csv
// are encouraged to register themselves in this map at package init time.
// (Doing this at package init time ensures this map can be accessed without race conditions.)
//
// This registry map is only used for default behaviors.
// For example, linking/cid.DefaultLinkSystem will use LookupEncoder to access this registry map
// and select encoders to use when serializing data for linking and storage.
// LinkSystem itself is not hardcoded to use the global LookupEncoder feature;
// therefore, you don't want to rely on this mapping, you can always construct your own LinkSystem.
//
// No effort is made to detect conflicting registrations in this map.
// If your dependency tree is such that this becomes a problem,
// there are two ways to address this:
// If RegisterEncoder is called with the same indicator code more than once, the last call wins.
// In practice, this means that if an application has a strong opinion about what implementation for a certain codec,
// then this can be done by making a Register call with that effect at init time in the application's main package.
// This should have the desired effect because the root of the import tree has its init time effect last.
// Alternatively, one can just avoid use of this registry entirely:
// do this by making a LinkSystem that uses a custom EncoderChooser function.
RegisterEncoder updates a simple map of multicodec indicator number to ipld.Encoder function.
The encoder functions registered can be subsequently looked up using LookupEncoder.



This registry map is only used for default behaviors.
For example, linking/cid.DefaultLinkSystem will use LookupEncoder to access this registry map
and select encoders to use when serializing data for linking and storage.
LinkSystem itself is not hardcoded to use the global LookupEncoder feature;
therefore, you don't want to rely on this mapping, you can always construct your own LinkSystem.

No effort is made to detect conflicting registrations in this map.
If your dependency tree is such that this becomes a problem,
there are two ways to address this:
If RegisterEncoder is called with the same indicator code more than once, the last call wins.
In practice, this means that if an application has a strong opinion about what implementation for a certain codec,
then this can be done by making a Register call with that effect at init time in the application's main package.
This should have the desired effect because the root of the import tree has its init time effect last.
Alternatively, one can just avoid use of this registry entirely:
do this by making a LinkSystem that uses a custom EncoderChooser function.
// RegisterEncoder updates a simple map of multicodec indicator number to ipld . Encoder function . // The encoder functions registered can be subsequently looked up using LookupEncoder . // // Packages which implement an IPLD codec and have a multicodec number reserved in // https : // github . com / multiformats / multicodec / blob / master / table . csv // are encouraged to register themselves in this map at package init time . // ( Doing this at package init time ensures this map can be accessed without race conditions . ) // // This registry map is only used for default behaviors . // For example linking / cid . DefaultLinkSystem will use LookupEncoder to access this registry map // and select encoders to use when serializing data for linking and storage . // LinkSystem itself is not hardcoded to use the global LookupEncoder feature ; // therefore you don ' t want to rely on this mapping you can always construct your own LinkSystem . // // No effort is made to detect conflicting registrations in this map . // If your dependency tree is such that this becomes a problem // there are two ways to address this : // If RegisterEncoder is called with the same indicator code more than once the last call wins . // In practice this means that if an application has a strong opinion about what implementation for a certain codec // then this can be done by making a Register call with that effect at init time in the application ' s main package . // This should have the desired effect because the root of the import tree has its init time effect last . // Alternatively one can just avoid use of this registry entirely : // do this by making a LinkSystem that uses a custom EncoderChooser function .
func RegisterEncoder(indicator uint64, encodeFunc ipld.Encoder) {
	if encodeFunc == nil {
		panic("not sensible to attempt to register a nil function")
	}
	encoderRegistry[indicator] = encodeFunc
}
func RegisterEncoder ( indicator uint64 , encodeFunc ipld . Encoder ) { if encodeFunc == nil { panic ( " " ) } encoderRegistry [ indicator ] = encodeFunc }
RegisterEncoder updates a simple map of multicodec indicator number to ipld.Encoder function.
RegisterEncoder updates a simple map of multicodec indicator number to ipld . Encoder function .
// This function could arguably be just a bare map access. // We introduced a function primarily for the interest of potential future changes. // E.g. one could introduce logging here to help detect unintended conflicting registrations. // (We probably won't do this, but you can do it yourself as a printf debug hack. :))