=encoding utf-8

=head1 NAME

HTTP::Promise::Body::Scalar - HTTP Message Body Scalar Class

=head1 SYNOPSIS

    use HTTP::Promise::Body;
    my $body = HTTP::Promise::Body::Scalar->new || 
        die( HTTP::Promise::Body::Scalar->error, "\n" );
    my $body = HTTP::Promise::Body::Scalar->new( $some_data );

    if( $body->is_empty )
    {
        # do something
    }

    my $size = $body->length;

    # $io is a Module::Generic::Scalar::IO object
    my $io = $body->open( 'r' ) || die( $body->error );
    $io->read( $buffer, 2048 );
    $io->close;

    my $io = $body->open( 'r', { binmode => 'utf-8' } ) || die( $body->error );
    $io->read( $buffer, 2048 );
    $io->close;

    # open the body as an utf-8 stream and print it to filehandle $filehandle
    $body->print( $filehandle, { binmode => 'utf-8' } );

    # $lines is a new Module::Generic::Array
    my $lines = $body->split( qr/\n/ );

    $body->purge;
    # ditto
    $body->reset;

=head1 VERSION

    v0.1.0

=head1 DESCRIPTION

This class represents an entity body as a scalar.

This class inherits from L<HTTP::Promise::Body> and L<Module::Generic::Scalar>

=head1 METHODS

Methods superseded by this class are as follow.

=head2 as_string

This returns a new L<scalar object|Module::Generic::Scalar> containing the body data.

=head2 checksum_md5

Returns a md6 checksum of the body data using L<Crypt::Digest::MD5>.

=for Pod::Coverage error

=for Pod::Coverage pass_error

=head2 path

This returns nothing since there is no filepath for an all-memory body data

=head2 purge

This calls L<Module::Generic::Scalar/reset> to empty the underlying body data.

=head1 AUTHOR

Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>

=head1 SEE ALSO

L<HTTP::Promise>, L<HTTP::Promise::Request>, L<HTTP::Promise::Response>, L<HTTP::Promise::Message>, L<HTTP::Promise::Entity>, L<HTTP::Promise::Headers>, L<HTTP::Promise::Body>, L<HTTP::Promise::Body::Form>, L<HTTP::Promise::Body::Form::Data>, L<HTTP::Promise::Body::Form::Field>, L<HTTP::Promise::Status>, L<HTTP::Promise::MIME>, L<HTTP::Promise::Parser>, L<HTTP::Promise::IO>, L<HTTP::Promise::Stream>, L<HTTP::Promise::Exception>

L<Module::Generic::File>, L<Module::Generic::Scalar>, L<Module::Generic::File::IO>, L<Module::Generic::Scalar::IO>

L<PerlIO::scalar>

=head1 COPYRIGHT & LICENSE

Copyright(c) 2022 DEGUEST Pte. Ltd.

All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

=cut