Skip to content

Commit 9f3b1db

Browse files
committed
doc(driver): alignment requirement of RecvMsg/SendMsg
1 parent c563e1c commit 9f3b1db

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

compio-driver/src/iocp/op.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,10 @@ pub struct RecvMsg<T: IoVectoredBufMut, C: IoBufMut, S> {
791791

792792
impl<T: IoVectoredBufMut, C: IoBufMut, S> RecvMsg<T, C, S> {
793793
/// Create [`RecvMsgVectored`].
794+
///
795+
/// # Panics
796+
///
797+
/// This function will panic if the control message buffer is misaligned.
794798
pub fn new(fd: SharedFd<S>, buffer: T, control: C) -> Self {
795799
assert!(
796800
control.as_buf_ptr().cast::<CMSGHDR>().is_aligned(),
@@ -862,6 +866,10 @@ pub struct SendMsg<T: IoVectoredBuf, C: IoBuf, S> {
862866

863867
impl<T: IoVectoredBuf, C: IoBuf, S> SendMsg<T, C, S> {
864868
/// Create [`SendMsgVectored`].
869+
///
870+
/// # Panics
871+
///
872+
/// This function will panic if the control message buffer is misaligned.
865873
pub fn new(fd: SharedFd<S>, buffer: T, control: C, addr: SockAddr) -> Self {
866874
assert!(
867875
control.as_buf_ptr().cast::<CMSGHDR>().is_aligned(),

compio-driver/src/unix/op.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,10 @@ pub struct RecvMsg<T: IoVectoredBufMut, C: IoBufMut, S> {
383383

384384
impl<T: IoVectoredBufMut, C: IoBufMut, S> RecvMsg<T, C, S> {
385385
/// Create [`RecvMsgVectored`].
386+
///
387+
/// # Panics
388+
///
389+
/// This function will panic if the control message buffer is misaligned.
386390
pub fn new(fd: SharedFd<S>, buffer: T, control: C) -> Self {
387391
assert!(
388392
control.as_buf_ptr().cast::<libc::cmsghdr>().is_aligned(),
@@ -433,6 +437,10 @@ pub struct SendMsg<T: IoVectoredBuf, C: IoBuf, S> {
433437

434438
impl<T: IoVectoredBuf, C: IoBuf, S> SendMsg<T, C, S> {
435439
/// Create [`SendMsgVectored`].
440+
///
441+
/// # Panics
442+
///
443+
/// This function will panic if the control message buffer is misaligned.
436444
pub fn new(fd: SharedFd<S>, buffer: T, control: C, addr: SockAddr) -> Self {
437445
assert!(
438446
control.as_buf_ptr().cast::<libc::cmsghdr>().is_aligned(),

0 commit comments

Comments
 (0)