From 1ae388438ff5a5e6918da923a3d4b7aee21381de Mon Sep 17 00:00:00 2001 From: Timothy Messier Date: Thu, 4 Nov 2021 11:35:15 -0400 Subject: [PATCH] feat(subtypes): Add function to provide all known prefixes --- internal/types/subtypes/registry.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/types/subtypes/registry.go b/internal/types/subtypes/registry.go index 10462cbd5..a6a956357 100644 --- a/internal/types/subtypes/registry.go +++ b/internal/types/subtypes/registry.go @@ -70,6 +70,18 @@ func (r *Registry) SubtypeFromId(id string) Subtype { return subtype } +// Prefixes returns the list of all known Prefixes. +func (r *Registry) Prefixes() []string { + r.RLock() + defer r.RUnlock() + + ret := make([]string, 0, len(r.subtypesPrefixes)) + for p := range r.subtypesPrefixes { + ret = append(ret, p) + } + return ret +} + // Register registers all the prefixes for a provided Subtype. Register returns // an error if the subtype has already been registered or if any of the // prefixes are associated with another subtype.