Haio 0.2.X
Homebrew Asset IO/CDN
Loading...
Searching...
No Matches
Haio::Pipe Namespace Reference

Namespaces

namespace  Detail

Classes

struct  Stage

Functions

template<typename A, typename B>
constexpr auto operator| (Stage< A > first, Stage< B > second)
template<typename Fn>
auto operator>> (std::istream &in, const Stage< Fn > &stage)

Variables

constexpr auto Decode
template<Color To>
constexpr auto Convert
template<Format F>
constexpr auto Encode

Detailed Description

lazily composed conversions, checked when the chain is built rather than when it runs. a stage is a callable returning Result<T>, and chaining two short circuits: the second never runs if the first failed, and the error rides through untouched.

const auto pipeline = Decode | Convert<Color::ETC1> | Encode<Format::KTX2>;
const auto result = pipeline(bytes);

the names repeat those in Haio::Codecs on purpose: a stage is a value that composes, not a function that runs, so Pipe::Encode<Format::KTX2> is a thing you hold and Codecs::Encode<Format::KTX2, Color::ETC1> is a thing you call.

Function Documentation

◆ operator>>()

template<typename Fn>
auto Haio::Pipe::operator>> ( std::istream & in,
const Stage< Fn > & stage )

the result type follows whatever the chain ends in, image or blob

Definition at line 80 of file haio_pipe.hpp.

Here is the call graph for this function:

◆ operator|()

template<typename A, typename B>
auto Haio::Pipe::operator| ( Stage< A > first,
Stage< B > second )
constexpr

Definition at line 33 of file haio_pipe.hpp.

Here is the call graph for this function:

Variable Documentation

◆ Convert

template<Color To>
auto Haio::Pipe::Convert
inlineconstexpr
Initial value:
= Stage{[]<Color From>(Image<From> src) -> Result<Image<To>>
return Codecs::Convert<From, To>(std::move(src));
}}
Result< Image< To > > Convert(Image< From >)=delete
std::expected< T, Error > Result

the target colour is named, the source is deduced from whatever arrives

Definition at line 66 of file haio_pipe.hpp.

◆ Decode

auto Haio::Pipe::Decode
inlineconstexpr
Initial value:
= Stage{[](const auto& in) -> Result<Image<Color::RGBA8888>> {
}}
Blob asBlob(const Blob &in)
Definition haio_pipe.hpp:44

the bytes say what they are, nobody has to know beforehand.

Todo
the output is pinned to rgba8888 because a pipeline is typed and the input is not. a jpeg is natively yuv, so asking for y4m through here would go through rgb for nothing; Codecs::Decode<Format::JPEG, Color::YUV420> is the way around it.

Definition at line 60 of file haio_pipe.hpp.

◆ Encode

template<Format F>
auto Haio::Pipe::Encode
inlineconstexpr
Initial value:
= Stage{[]<Color P>(Image<P> src) -> Result<Blob>
return Codecs::Encode<F, P>(std::move(src));
}}
Result< Blob > Encode(Image< P >)=delete

the container is named, the colour comes from the image in hand

Definition at line 73 of file haio_pipe.hpp.