Skip to content

Commit

Permalink
Cleaning up ToPayload implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-summers committed Sep 13, 2023
1 parent 3113135 commit 2158721
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/publication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ impl<'a> ToPayload for &'a str {
}
}

impl<const N: usize> ToPayload for [u8; N] {
type Error = ();

fn serialize(self, buffer: &mut [u8]) -> Result<usize, ()> {
(&self[..]).serialize(buffer)
}
}
impl<const N: usize> ToPayload for &[u8; N] {
type Error = ();

Expand All @@ -45,6 +38,12 @@ impl<const N: usize> ToPayload for &[u8; N] {
}
}

/// A publication where the payload is serialized directly into the transmission buffer in the
/// future.
///
/// # Note
/// This is "deferred" because the closure will only be called once the publication is actually
/// sent.
pub struct DeferredPublication<E, F: FnOnce(&mut [u8]) -> Result<usize, E>> {
func: F,
}
Expand Down

0 comments on commit 2158721

Please sign in to comment.