From 60c08f0a418df148793870cdbde4b2a2cec73bd0 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Tue, 25 May 2021 15:25:43 +0200 Subject: Rename tagged union fields in znk --- src/nkeys.zig | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/nkeys.zig') 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) { private = 15 << 3, // P fn char(self: Self) u8 { - switch (self) { + return switch (self) { .seed => 'S', .private => 'P', - } + }; } fn fromChar(c: u8) InvalidPrefixByteError!Self { @@ -61,6 +61,16 @@ pub const PublicPrefixByte = enum(u8) { }; } + fn char(self: Self) u8 { + return switch (self) { + .account => 'A', + .cluster => 'C', + .operator => 'O', + .server => 'N', + .user => 'U', + }; + } + fn fromChar(c: u8) InvalidPrefixByteError!Self { return switch (c) { 'A' => .account, @@ -464,6 +474,8 @@ pub fn parseDecoratedUserNkey(contents: []const u8) (NoNkeySeedFoundError || NoN test { testing.refAllDecls(@This()); + testing.refAllDecls(KeyTypePrefixByte); + testing.refAllDecls(PublicPrefixByte); testing.refAllDecls(SeedKeyPair); testing.refAllDecls(PublicKey); testing.refAllDecls(PrivateKey); -- cgit v1.2.3