Skip to main content

ready_commit/
ready_commit.rs

1//! Shows the consuming READY/COMMIT API boundary on every native backend.
2//!
3//! Real capability transfer requires two authenticated processes. These helper
4//! functions make the compile-time transition explicit without creating an
5//! unauthenticated demonstration transport.
6
7#![allow(dead_code)] // The target-specific signatures are the example output.
8
9use native_ipc_core::layout::{RegionSetLayout, ValidationExpectations};
10
11#[cfg(target_os = "linux")]
12fn creator(
13    channel: &mut native_ipc_platform::linux::AuthenticatedChannel,
14    prepared: native_ipc_platform::linux::PreparedWriter,
15) -> Result<
16    native_ipc_core::mapping::WriterRegion<native_ipc_platform::linux::LinuxWriterMapping>,
17    native_ipc_platform::linux::LinuxError,
18> {
19    channel.transfer_writer(prepared)
20}
21
22#[cfg(target_os = "linux")]
23fn peer(
24    channel: &mut native_ipc_platform::linux::AuthenticatedChannel,
25    len: usize,
26    expected: ValidationExpectations,
27    topology: RegionSetLayout,
28) -> Result<
29    native_ipc_core::mapping::ReaderRegion<native_ipc_platform::linux::LinuxReaderMapping>,
30    native_ipc_platform::linux::LinuxError,
31> {
32    channel.receive_reader(len, expected, topology)
33}
34
35#[cfg(target_os = "macos")]
36fn creator(
37    channel: &mut native_ipc_platform::macos::bootstrap::ParentChannel,
38    writer: native_ipc_platform::macos::PendingTransferredWriter,
39    reader: native_ipc_platform::macos::PendingTransferredReader,
40) -> Result<
41    (
42        native_ipc_core::mapping::WriterRegion<
43            native_ipc_platform::macos::TransferredWriterMapping,
44        >,
45        native_ipc_core::mapping::ReaderRegion<
46            native_ipc_platform::macos::TransferredReaderMapping,
47        >,
48    ),
49    native_ipc_platform::macos::MacBindingError,
50> {
51    channel.commit_transfers(writer, reader)
52}
53
54#[cfg(target_os = "windows")]
55fn creator(
56    session: &mut native_ipc_platform::windows::ChildSession,
57    writer: native_ipc_platform::windows::PreparedLocalWriter,
58    reader: native_ipc_platform::windows::PreparedRemoteWriter,
59) -> Result<
60    (
61        native_ipc_core::mapping::WriterRegion<native_ipc_platform::windows::WindowsWriterMapping>,
62        native_ipc_core::mapping::ReaderRegion<native_ipc_platform::windows::WindowsReaderMapping>,
63    ),
64    native_ipc_platform::windows::WindowsError,
65> {
66    session.commit_transfers(writer, reader)
67}
68
69fn main() {
70    let _ = std::mem::size_of::<ValidationExpectations>();
71    let _ = std::mem::size_of::<RegionSetLayout>();
72    println!("pending mappings expose runtime access only after COMMIT");
73}