Skip to content

MigaduMail/ex_imap_codec

Repository files navigation

ExImapCodec

A small wrapper around the imap-codec rust library.

So far only the decoder has been implemented.

The result of the decode command is a struct with:

  • the original input string in "original_command"
  • the parsed command as a json string in "command"
  • the arguments in "arguments" string
  • the tag in "tag" string

Installation

def deps do
  [
    {:ex_imap_codec, "~> 0.1.0"}
  ]
end

Example

iex(1)> a = ExImapCodec.decode_imap_command "a login aaa bbb\r\n"
%{
  __struct__: ExImapCodec.CommandResult,
  arguments: %{},
  command_type: "{\n  \"Login\": {\n    \"username\": {\n      \"Atom\": \"aaa\"\n    },\n    \"password\": {\n      \"Atom\": \"bbb\"\n    }\n  }\n}",
  original_command: "a login aaa bbb\r\n",
  tag: "a"
}
iex(2)> str = "a002 SELECT INBOX\r\n"; ExImapCodec.decode_imap_command(str)
%{
  __struct__: ExImapCodec.CommandResult,
  arguments: %{},
  command_type: "{\n  \"Select\": {\n    \"mailbox\": \"Inbox\"\n  }\n}",
  original_command: "a002 SELECT INBOX\r\n",
  tag: "a002"
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published