use core::fmt;
use super::PreparedRequest;
pub struct PreparationStorage<'storage> {
target: &'storage mut [u8],
body: &'storage mut [u8],
}
impl<'storage> PreparationStorage<'storage> {
#[must_use]
pub const fn new(target: &'storage mut [u8], body: &'storage mut [u8]) -> Self {
Self { target, body }
}
#[must_use]
pub fn into_parts(self) -> (&'storage mut [u8], &'storage mut [u8]) {
(self.target, self.body)
}
}
impl fmt::Debug for PreparationStorage<'_> {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter
.debug_struct("PreparationStorage")
.field("target_capacity", &self.target.len())
.field("body_capacity", &self.body.len())
.finish()
}
}
pub trait PrepareOperation {
type Error;
fn prepare<'storage>(
&self,
storage: PreparationStorage<'storage>,
) -> Result<PreparedRequest<'storage>, Self::Error>;
}