summaryrefslogtreecommitdiff
path: root/vendor/github.com/authzed/spicedb/pkg/namespace/mapper.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/authzed/spicedb/pkg/namespace/mapper.go')
-rw-r--r--vendor/github.com/authzed/spicedb/pkg/namespace/mapper.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/github.com/authzed/spicedb/pkg/namespace/mapper.go b/vendor/github.com/authzed/spicedb/pkg/namespace/mapper.go
new file mode 100644
index 0000000..148ca8e
--- /dev/null
+++ b/vendor/github.com/authzed/spicedb/pkg/namespace/mapper.go
@@ -0,0 +1,27 @@
+package namespace
+
+// Mapper provides an interface for creating synthetic namespace names from
+// user provided namespace names.
+type Mapper interface {
+ // Encode translates a given namespace name to an encoded namespace identifier.
+ Encode(name string) (string, error)
+
+ // Reverse translates a given namespace identifier to the user supplied namespace name.
+ Reverse(id string) (string, error)
+}
+
+type passthrough struct{}
+
+// Encode implements Mapper
+func (p passthrough) Encode(name string) (string, error) {
+ return name, nil
+}
+
+// Reverse implements Mapper
+func (p passthrough) Reverse(id string) (string, error) {
+ return id, nil
+}
+
+// PassthroughMapper is a mapper implementation which passes through the original namespace
+// names unmodified.
+var PassthroughMapper Mapper = passthrough{}