aboutsummaryrefslogtreecommitdiffstats
path: root/src/nkeys.zig
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2021-05-25 15:25:43 +0200
committerLibravatar Rutger Broekhoff2021-05-25 15:25:43 +0200
commit60c08f0a418df148793870cdbde4b2a2cec73bd0 (patch)
tree67041a5a59a234fe71d154c73b31855086f0c636 /src/nkeys.zig
parent7914eed7b4a37b9c0b0da9aa9481d9666353b45e (diff)
downloadzig-nkeys-60c08f0a418df148793870cdbde4b2a2cec73bd0.tar.gz
zig-nkeys-60c08f0a418df148793870cdbde4b2a2cec73bd0.zip
Rename tagged union fields in znk
Diffstat (limited to 'src/nkeys.zig')
-rw-r--r--src/nkeys.zig16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/nkeys.zig b/src/nkeys.zig
index ac5ba1b..42a781f 100644
--- a/src/nkeys.zig
+++ b/src/nkeys.zig
@@ -26,10 +26,10 @@ pub const KeyTypePrefixByte = enum(u8) {
26 private = 15 << 3, // P 26 private = 15 << 3, // P
27 27
28 fn char(self: Self) u8 { 28 fn char(self: Self) u8 {
29 switch (self) { 29 return switch (self) {
30 .seed => 'S', 30 .seed => 'S',
31 .private => 'P', 31 .private => 'P',
32 } 32 };
33 } 33 }
34 34
35 fn fromChar(c: u8) InvalidPrefixByteError!Self { 35 fn fromChar(c: u8) InvalidPrefixByteError!Self {
@@ -61,6 +61,16 @@ pub const PublicPrefixByte = enum(u8) {
61 }; 61 };
62 } 62 }
63 63
64 fn char(self: Self) u8 {
65 return switch (self) {
66 .account => 'A',
67 .cluster => 'C',
68 .operator => 'O',
69 .server => 'N',
70 .user => 'U',
71 };
72 }
73
64 fn fromChar(c: u8) InvalidPrefixByteError!Self { 74 fn fromChar(c: u8) InvalidPrefixByteError!Self {
65 return switch (c) { 75 return switch (c) {
66 'A' => .account, 76 'A' => .account,
@@ -464,6 +474,8 @@ pub fn parseDecoratedUserNkey(contents: []const u8) (NoNkeySeedFoundError || NoN
464 474
465test { 475test {
466 testing.refAllDecls(@This()); 476 testing.refAllDecls(@This());
477 testing.refAllDecls(KeyTypePrefixByte);
478 testing.refAllDecls(PublicPrefixByte);
467 testing.refAllDecls(SeedKeyPair); 479 testing.refAllDecls(SeedKeyPair);
468 testing.refAllDecls(PublicKey); 480 testing.refAllDecls(PublicKey);
469 testing.refAllDecls(PrivateKey); 481 testing.refAllDecls(PrivateKey);