Skip to content

Commit 9ab0c4a

Browse files
committed
feat: add support for merging l2cap channel halfs
1 parent 084b5ac commit 9ab0c4a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

host/src/l2cap.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,21 @@ where {
206206
},
207207
)
208208
}
209+
210+
/// Merge writer and reader into a single channel again.
211+
///
212+
/// This function will panic if the channels are not referring to the same channel id.
213+
pub fn merge(writer: L2capChannelWriter<'d>, reader: L2capChannelReader<'d>) -> Self {
214+
// A channel will not be reused unless the refcount is 0, so the index could
215+
// never be stale.
216+
assert_eq!(writer.index, reader.index);
217+
218+
let manager = writer.manager;
219+
let index = writer.index;
220+
manager.inc_ref(index);
221+
222+
Self { index, manager }
223+
}
209224
}
210225

211226
impl<'d> L2capChannelReader<'d> {

0 commit comments

Comments
 (0)