.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Mojo::Asset 3"
.TH Mojo::Asset 3 "2023-03-08" "perl v5.26.3" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Mojo::Asset \- HTTP content storage base class
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
\& package Mojo::Asset::MyAsset;
\& use Mojo::Base \*(AqMojo::Asset\*(Aq;
\&
\& sub add_chunk {...}
\& sub contains {...}
\& sub get_chunk {...}
\& sub move_to {...}
\& sub mtime {...}
\& sub size {...}
\& sub slurp {...}
\& sub to_file {...}
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Mojo::Asset is an abstract base class for \s-1HTTP\s0 content storage backends, like Mojo::Asset::File and
Mojo::Asset::Memory.
.SH "EVENTS"
.IX Header "EVENTS"
Mojo::Asset inherits all events from Mojo::EventEmitter.
.SH "ATTRIBUTES"
.IX Header "ATTRIBUTES"
Mojo::Asset implements the following attributes.
.SS "end_range"
.IX Subsection "end_range"
.Vb 2
\& my $end = $asset\->end_range;
\& $asset = $asset\->end_range(8);
.Ve
.PP
Pretend file ends earlier.
.SS "start_range"
.IX Subsection "start_range"
.Vb 2
\& my $start = $asset\->start_range;
\& $asset = $asset\->start_range(3);
.Ve
.PP
Pretend file starts later.
.SH "METHODS"
.IX Header "METHODS"
Mojo::Asset inherits all methods from Mojo::EventEmitter and implements the following new ones.
.SS "add_chunk"
.IX Subsection "add_chunk"
.Vb 1
\& $asset = $asset\->add_chunk(\*(Aqfoo bar baz\*(Aq);
.Ve
.PP
Add chunk of data to asset. Meant to be overloaded in a subclass.
.SS "contains"
.IX Subsection "contains"
.Vb 1
\& my $position = $asset\->contains(\*(Aqbar\*(Aq);
.Ve
.PP
Check if asset contains a specific string. Meant to be overloaded in a subclass.
.SS "get_chunk"
.IX Subsection "get_chunk"
.Vb 2
\& my $bytes = $asset\->get_chunk($offset);
\& my $bytes = $asset\->get_chunk($offset, $max);
.Ve
.PP
Get chunk of data starting from a specific position, defaults to a maximum chunk size of \f(CW131072\fR bytes (128KiB).
Meant to be overloaded in a subclass.
.SS "is_file"
.IX Subsection "is_file"
.Vb 1
\& my $bool = $asset\->is_file;
.Ve
.PP
False, this is not a Mojo::Asset::File object.
.SS "is_range"
.IX Subsection "is_range"
.Vb 1
\& my $bool = $asset\->is_range;
.Ve
.PP
Check if asset has a \*(L"start_range\*(R" or \*(L"end_range\*(R".
.SS "move_to"
.IX Subsection "move_to"
.Vb 1
\& $asset = $asset\->move_to(\*(Aq/home/sri/foo.txt\*(Aq);
.Ve
.PP
Move asset data into a specific file. Meant to be overloaded in a subclass.
.SS "mtime"
.IX Subsection "mtime"
.Vb 1
\& my $mtime = $asset\->mtime;
.Ve
.PP
Modification time of asset. Meant to be overloaded in a subclass.
.SS "size"
.IX Subsection "size"
.Vb 1
\& my $size = $asset\->size;
.Ve
.PP
Size of asset data in bytes. Meant to be overloaded in a subclass.
.SS "slurp"
.IX Subsection "slurp"
.Vb 1
\& my $bytes = $asset\->slurp;
.Ve
.PP
Read all asset data at once. Meant to be overloaded in a subclass.
.SS "to_file"
.IX Subsection "to_file"
.Vb 1
\& my $file = $asset\->to_file;
.Ve
.PP
Convert asset to Mojo::Asset::File object. Meant to be overloaded in a subclass.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.