Flux::Format - interface for symmetric two-way formatting of any storage.
version 1.03
$json_storage = $json_format->wrap($storage); $json_storage->write({ a => "b" }); $in = $json_storage->in("client1"); $data = $in->read(); # data is decoded again
There's a common need to store complex data into storages which can only store strings.
Simple Flux::Mapper is not enough, because storage should both serialize and deserialize data in the same way. Flux::Format provides the common interface for objects which can decorate Flux::Storage objects into storages which can both write data through a serializing mapper and create reading streams which deserialize that data on reads.
Flux::Mapper
Flux::Format
Flux::Storage
Usual method to create new formatters is to apply this role and implement encoder and decoder methods.
encoder
decoder
This method should return a mapper which will be applied to any item written into wrapped storage.
Mapper is expected to support Flux::Mapper interface and to transform data in 1-to-1 fashion.
This method should return a mapper which will be applied to any item read from an input stream created from a wrapped storage.
Mapper is expected to support Flux::Mapper interface to transform data in 1-to-1 fashion.
Construct a formatted storage. Returns a new storage object.
Resulting object will transform all writes using encoder and generate input streams which are pre-decoded by decoder.
Unlike encoder and decoder, this method is provided by this role.
Vyacheslav Matyukhin <me@berekuk.ru>
This software is copyright (c) 2013 by Yandex LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Flux, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Flux
CPAN shell
perl -MCPAN -e shell install Flux
For more information on module installation, please visit the detailed CPAN module installation guide.