From 72906c6bb473ea605235c84b6d01c318f7b6cef8 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 5 Nov 2018 15:03:31 +0100 Subject: File shard quite complete (but not perfect) --- shardweb/lib/shard_uri.ex | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 shardweb/lib/shard_uri.ex (limited to 'shardweb') diff --git a/shardweb/lib/shard_uri.ex b/shardweb/lib/shard_uri.ex deleted file mode 100644 index 71c0904..0000000 --- a/shardweb/lib/shard_uri.ex +++ /dev/null @@ -1,42 +0,0 @@ -defmodule ShardURI do - @moduledoc""" - Convert Shard manifests to and from strings. - """ - - def from_manifest(m) do - case m do - %SApp.Chat.Manifest{channel: chan} -> "shard:chat:#{chan}" - %SApp.Chat.PrivChat.Manifest{pk_list: pk_list} -> - "shard:privchat:#{pk_list|>Enum.map(&Base.encode16/1)|>Enum.join(",")}" - %SApp.Identity.Manifest{pk: pk} -> - "shard:identity:#{pk|>Base.encode16}" - %SApp.Directory.Manifest{owner: owner, public: true, name: name} -> - "shard:dir:pub:#{owner|>Base.encode16}:#{name}" - %SApp.Directory.Manifest{owner: owner, public: false, name: name} -> - "shard:dir:priv:#{owner|>Base.encode16}:#{name}" - end - end - - def to_manifest(p) do - case p do - "shard:chat:" <> chan -> - %SApp.Chat.Manifest{channel: chan} - "shard:privchat:" <> pklist -> - pklist - |> String.split(",") - |> Enum.map(&parse_pk/1) - |> SApp.Chat.PrivChat.Manifest.new() - "shard:identity:" <> pk -> - %SApp.Identity.Manifest{pk: parse_pk pk} - "shard:dir:pub:" <> <> <> ":" <> name -> - %SApp.Directory.Manifest{owner: parse_pk(pk), public: true, name: name} - "shard:dir:priv:" <> <> <> ":" <> name -> - %SApp.Directory.Manifest{owner: parse_pk(pk), public: false, name: name} - end - end - - def parse_pk(pkstr) do - 64 = byte_size pkstr - Base.decode16! pkstr - end -end -- cgit v1.2.3