summaryrefslogtreecommitdiff
path: root/lib/MaildirIndexer/Parser.pm6
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MaildirIndexer/Parser.pm6')
-rw-r--r--lib/MaildirIndexer/Parser.pm654
1 files changed, 35 insertions, 19 deletions
diff --git a/lib/MaildirIndexer/Parser.pm6 b/lib/MaildirIndexer/Parser.pm6
index a193f75..7780a62 100644
--- a/lib/MaildirIndexer/Parser.pm6
+++ b/lib/MaildirIndexer/Parser.pm6
@@ -1,5 +1,6 @@
use v6.d.PREVIEW;
unit module MaildirIndexer::Parser;
+use MaildirIndexer::LogTimelineSchema;
use MaildirIndexer::Email;
my @separators = (
@@ -58,35 +59,50 @@ my class Message-actions {
}
multi parse-email(IO::Path:D $p --> MaildirIndexer::Email) is export {
- return parse-email($p.slurp(:enc<utf8-c8>), path => $p);
+ my MaildirIndexer::Email $result;
+ MaildirIndexer::LogTimelineSchema::Parse::Email::File.log: :file($p.path), -> {
+ $result = parse-email($p.slurp(:enc<utf8-c8>), path => $p);
+ }
+ return $result;
}
multi parse-email(IO::Path:D $p, :$headers-only! --> MaildirIndexer::Email) is export {
- return parse-email(
- $p.lines(
- :enc<utf8-c8>,
- :nl-in(@separators),
- :!chomp,
- )[0],
- path => $p,
- );
+ my MaildirIndexer::Email $result;
+ MaildirIndexer::LogTimelineSchema::Parse::Email::File.log: :file($p.path), -> {
+ $result = parse-email(
+ $p.lines(
+ :enc<utf8-c8>,
+ :nl-in(@separators),
+ :!chomp,
+ )[0],
+ path => $p,
+ );
+ }
+ return $result;
}
multi parse-email(IO::Socket::Async:D $s --> MaildirIndexer::Email) is export {
- my $string;
- react {
- whenever $s.Supply(:enc<utf8-c8>) {
- $string ~= $_;
- done if $string ~~ /@separators/;
+ my MaildirIndexer::Email $result;
+ MaildirIndexer::LogTimelineSchema::Parse::Email::Socket.log: -> {
+ my $string;
+ react {
+ whenever $s.Supply(:enc<utf8-c8>) {
+ $string ~= $_;
+ done if $string ~~ /@separators/;
+ }
}
+ $result = parse-email($string);
}
- return parse-email($string);
+ return $result;
}
multi parse-email(Str:D $email-str, :$path = IO --> MaildirIndexer::Email) is export {
- CATCH { warn .perl; return Nil };
- with Message.parse($email-str,:actions(Message-actions.new(:$path))) {
- return .made;
+ my MaildirIndexer::Email $result;
+ MaildirIndexer::LogTimelineSchema::Parse::Email::Str.log: -> {
+ CATCH { warn .perl; return Nil };
+ with Message.parse($email-str,:actions(Message-actions.new(:$path))) {
+ $result = .made;
+ }
}
- return Nil;
+ return $result;
}