| 1 | package Dallycot::Channel; | ||
| 2 | our $AUTHORITY = 'cpan:JSMITH'; | ||
| 3 | |||
| 4 | # ABSTRACT: i/o channel base class | ||
| 5 | |||
| 6 | use utf8; | ||
| 7 | use Moose; | ||
| 8 | use Carp qw(croak); | ||
| 9 | |||
| 10 | sub can_send {return} | ||
| 11 | sub can_receive {return} | ||
| 12 | |||
| 13 | sub send_data { | ||
| 14 | my ( $self, @content ) = @_; | ||
| 15 | |||
| 16 | # This needs to be written for an output channel | ||
| 17 | my $class = ref $self || $self; | ||
| 18 | croak "send() is not implemented for $class"; | ||
| 19 | } | ||
| 20 | |||
| 21 | sub receive_data { | ||
| 22 | my ($self) = @_; | ||
| 23 | |||
| 24 | # This also needs to be written for an input channel | ||
| 25 | # should return a promise that will be fulfilled with the | ||
| 26 | # input when it arrives | ||
| 27 | my $class = ref $self || $self; | ||
| 28 | croak "receive() is not implemented for $class"; | ||
| 29 | } | ||
| 30 | |||
| 31 | __PACKAGE__ -> meta -> make_immutable; | ||
| 32 | |||
| 33 | 1; |