Mango:...:Binary(3pm)

πŸ“¦
version 1.30 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Mango:...:Binary(3pm) β€” bestie edition πŸ’–

okay so you're reading a Perl manual page from the User Contributed Perl Documentation collection, and it's all about Mango::BSON::Binary. pull up a chair, we're doing this together 🫢


✨ NAME ✨

Mango::BSON::Binary β€” it's the Binary type bestie, that's the whole vibe πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

use Mango::BSON::Binary;

my $bin = Mango::BSON::Binary->new(data => $bytes, type => 'generic');
say $bin->data;

look at that. clean. iconic. new with data and type, then you just say the data. periodt πŸ’…


🌸 DESCRIPTION 🌸

okay so Mango::BSON::Binary is a container for the BSON binary type that Mango::BSON uses. that's its whole job and it does it flawlessly, no notes.

and here's the cute part: for "JSON" implementations like Mojo::JSON that support the "TO_JSON" method, it will automatically "Base64" encode the binary data for you. it's giving ✨effortless✨. you don't even have to ask, it just handles it. obsessed.


πŸŽ€ ATTRIBUTES πŸŽ€

Mango::BSON::Binary implements the following attributes. yes, both of them, they're little but they're mighty πŸ“

πŸ’œ data

my $bytes = $bin->data;
$bin      = $bin->data($bytes);

this is the binary data itself. that's it. that's the attribute. the raw bytes, living their best life.

πŸ’œ type

my $type = $bin->type;
$bin     = $bin->type('generic');

this one's the binary subtype. and yeah, 'generic' is right there in the example if you need a default-ish vibe, iykyk.


πŸ”₯ METHODS πŸ”₯

Mango::BSON::Binary inherits all the methods from Mojo::Base (so it's already stacked before it even starts), and then it implements the following new ones:

⭐ TO_JSON

my $b64 = $bin->TO_JSON;

it Base64 encodes "data". that's the move. that's the entire move. slay πŸ’…


πŸ‘‘ OPERATORS πŸ‘‘

Mango::BSON::Binary overloads the following operators. yes, it's fancy like that.

πŸ¦‹ bool

my $bool = !!$bin;

Always true. always. no cap. it doesn't matter what's inside, this thing is truthy forever and ever, amen 🌈

πŸ¦‹ stringify

my $str = "$bin";

this is literally just an alias for "data". same energy, different syntax. πŸŽ€


🌈 SEE ALSO 🌈

go be nosy, bestie, these are your next tabs:


πŸ’€ quick vibe check: everything above is exactly what the page says, i just made it cuter. don't come for me.

okay bye ily, this page was brought to you by perl v5.30.3 on 2020-06-05 β€” yes she's a little vintage but she ate and left no crumbs 🫢✨🌸