#ifndef ADAPTERS_SMO_ASSEMBLE_FRAME_AREQ_H
#define ADAPTERS_SMO_ASSEMBLE_FRAME_AREQ_H

#include <adapters/smo/cpsCallbackAReq.h>
#include <spinscale/asynchronousLoop.h>
#include <spinscale/cps/callback.h>
#include <ioUringAssemblyEngine.h>

namespace smo {
namespace cpsBoundary {

struct AssembleFrameResult
{
	bool success = false;
	sscl::AsynchronousLoop loop{0};
};

inline CpsCallbackAReq<
	AssembleFrameResult,
	stim_buff::IoUringAssemblyEngine::assembleFrameReqCbFn,
	std::function<void(sscl::cps::Callback<
		stim_buff::IoUringAssemblyEngine::assembleFrameReqCbFn>)>>
getAssembleFrameReqAReqAwaiter(
	boost::asio::io_context &resumeIoContext,
	stim_buff::IoUringAssemblyEngine &engine)
{
	return CpsCallbackAReq<
		AssembleFrameResult,
		stim_buff::IoUringAssemblyEngine::assembleFrameReqCbFn,
		std::function<void(sscl::cps::Callback<
			stim_buff::IoUringAssemblyEngine::assembleFrameReqCbFn>)>>(
		resumeIoContext,
		[&engine](
			sscl::cps::Callback<
				stim_buff::IoUringAssemblyEngine::assembleFrameReqCbFn> cb)
		{
			engine.assembleFrameReq(std::move(cb));
		});
}

} // namespace cpsBoundary
} // namespace smo

#endif // ADAPTERS_SMO_ASSEMBLE_FRAME_AREQ_H
