microfmt
Zero-allocation C++ formatting for constrained environments
Loading...
Searching...
No Matches
Public Member Functions | List of all members
microfmt::asio_mutable_buffer_sink Class Reference

A sink adapter that writes formatted output directly into a boost::asio::mutable_buffer. More...

#include <asio_sink.hpp>

Public Member Functions

 asio_mutable_buffer_sink (boost::asio::mutable_buffer buf RELOCO_LIFETIMEBOUND RELOCO_LIFETIME_CAPTURE_BY_THIS) noexcept
 Constructs a sink over a Boost.Asio mutable buffer.
 
 asio_mutable_buffer_sink (const asio_mutable_buffer_sink &)=delete
 
asio_mutable_buffer_sink & operator= (const asio_mutable_buffer_sink &)=delete
 
 asio_mutable_buffer_sink (asio_mutable_buffer_sink &&) noexcept=default
 
asio_mutable_buffer_sink & operator= (asio_mutable_buffer_sink &&) noexcept=default
 
sink as_sink () noexcept RELOCO_LIFETIMEBOUND
 Creates a type-erased sink adapter pointing to this instance.
 
size_t size () const noexcept
 Returns the total number of bytes written to the buffer so far.
 
boost::asio::const_buffer written_buffer () const noexcept RELOCO_LIFETIMEBOUND
 Returns the written prefix of the wrapped buffer as a boost::asio::const_buffer, suitable for boost::asio::write / boost::asio::async_write.
 

Detailed Description

A sink adapter that writes formatted output directly into a boost::asio::mutable_buffer.

Wraps an externally provided buffer view (e.g. a coroutine's stack buffer) and exposes a non-owning, zero-allocation sink interface, mirroring span_sink. Tracks remaining capacity and truncates writes that exceed it instead of overflowing.

Constructor & Destructor Documentation

◆ asio_mutable_buffer_sink() [1/3]

microfmt::asio_mutable_buffer_sink::asio_mutable_buffer_sink ( boost::asio::mutable_buffer buf RELOCO_LIFETIMEBOUND  RELOCO_LIFETIME_CAPTURE_BY_THIS)
inlineexplicitnoexcept

Constructs a sink over a Boost.Asio mutable buffer.

Parameters
bufTarget mutable buffer. The memory it refers to must outlive this sink, and (via written_buffer) any pending async write that consumes its result.

◆ asio_mutable_buffer_sink() [2/3]

microfmt::asio_mutable_buffer_sink::asio_mutable_buffer_sink ( const asio_mutable_buffer_sink &  )
delete

◆ asio_mutable_buffer_sink() [3/3]

microfmt::asio_mutable_buffer_sink::asio_mutable_buffer_sink ( asio_mutable_buffer_sink &&  )
defaultnoexcept

Member Function Documentation

◆ as_sink()

sink microfmt::asio_mutable_buffer_sink::as_sink ( )
inlinenoexcept

Creates a type-erased sink adapter pointing to this instance.

◆ operator=() [1/2]

asio_mutable_buffer_sink & microfmt::asio_mutable_buffer_sink::operator= ( asio_mutable_buffer_sink &&  )
defaultnoexcept

◆ operator=() [2/2]

asio_mutable_buffer_sink & microfmt::asio_mutable_buffer_sink::operator= ( const asio_mutable_buffer_sink &  )
delete

◆ size()

size_t microfmt::asio_mutable_buffer_sink::size ( ) const
inlinenoexcept

Returns the total number of bytes written to the buffer so far.

◆ written_buffer()

boost::asio::const_buffer microfmt::asio_mutable_buffer_sink::written_buffer ( ) const
inlinenoexcept

Returns the written prefix of the wrapped buffer as a boost::asio::const_buffer, suitable for boost::asio::write / boost::asio::async_write.

The returned buffer aliases this sink's backing storage and must not outlive it.


The documentation for this class was generated from the following file: