diff options
Diffstat (limited to 'lib/MaildirIndexer/Parser.pm6')
-rw-r--r-- | lib/MaildirIndexer/Parser.pm6 | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/MaildirIndexer/Parser.pm6 b/lib/MaildirIndexer/Parser.pm6 index c2425fe..7b80ecf 100644 --- a/lib/MaildirIndexer/Parser.pm6 +++ b/lib/MaildirIndexer/Parser.pm6 @@ -58,6 +58,7 @@ class Message-actions { multi parse-email(IO::Path $p) is export { return parse-email($p.slurp(:enc<utf8-c8>)); } + multi parse-email(IO::Path $p, :$headers-only!) is export { return parse-email( $p.lines( @@ -67,6 +68,18 @@ multi parse-email(IO::Path $p, :$headers-only!) is export { )[0], ); } + +multi parse-email(IO::Socket::Async $s) is export { + my $string; + react { + whenever $s.Supply(:enc<utf8-c8>) { + $string ~= $_; + done if $string ~~ /@separators/; + } + } + return parse-email($string); +} + multi parse-email(Str $email-str) is export { with Message.parse($email-str,:actions(Message-actions.new)) { return .made; |