package Sietima::Types;
use 5.024;
use strict;
use warnings;
use Type::Utils -all;
use Types::Standard qw(Str HashRef);
use namespace::clean;
use Type::Library
-base,
-declare => qw(Address AddressFromStr
EmailMIME Message
Subscriber SubscriberFromAddress SubscriberFromStr SubscriberFromHashRef
Transport MailStore);
class_type EmailMIME, { class => 'Email::MIME' };
role_type Transport, { role => 'Email::Sender::Transport' };
role_type MailStore, { role => 'Sietima::MailStore' };
class_type Address, { class => 'Email::Address' };
declare_coercion AddressFromStr,
to_type Address, from Str,
q{ (Email::Address->parse($_))[0] };
class_type Message, { class => 'Sietima::Message' };
class_type Subscriber, { class => 'Sietima::Subscriber' };
declare_coercion SubscriberFromAddress,
to_type Subscriber, from Address,
q{ Sietima::Subscriber->new(raw_address=>$_) };
declare_coercion SubscriberFromStr,
to_type Subscriber, from Str,
q{ Sietima::Subscriber->new(raw_address=>(Email::Address->parse($_))[0]) };
declare_coercion SubscriberFromHashRef,
to_type Subscriber, from HashRef,
q{ Sietima::Subscriber->new($_) };
1;