11//! Platform shared-memory implementation for fspy channels.
22
3- #[ cfg( not( target_os = "linux" ) ) ]
3+ #[ cfg( not( any ( target_os = "linux" , target_os = "windows" ) ) ) ]
44use std:: io;
55#[ cfg( target_os = "linux" ) ]
66use std:: { future:: Future , io, pin:: Pin } ;
77
88#[ cfg( target_os = "linux" ) ]
99mod linux;
10+ #[ cfg( target_os = "windows" ) ]
11+ mod windows;
1012
1113#[ cfg( target_os = "linux" ) ]
1214pub use linux:: { CreatedShm , Shm , create, open} ;
13- #[ cfg( not( target_os = "linux" ) ) ]
15+ #[ cfg( not( any ( target_os = "linux" , target_os = "windows" ) ) ) ]
1416use shared_memory:: { Shmem , ShmemConf } ;
17+ #[ cfg( target_os = "windows" ) ]
18+ pub use windows:: { CreatedShm , Shm , create, open} ;
1519
1620/// A Linux service future that makes a shared-memory mapping available to other processes.
1721#[ cfg( target_os = "linux" ) ]
1822pub type ShmBroker = Pin < Box < dyn Future < Output = io:: Result < ( ) > > + Send + ' static > > ;
1923
2024/// An owned shared-memory mapping.
21- #[ cfg( not( target_os = "linux" ) ) ]
25+ #[ cfg( not( any ( target_os = "linux" , target_os = "windows" ) ) ) ]
2226pub struct Shm {
2327 inner : Shmem ,
2428}
2529
2630/// A newly created shared-memory mapping and its platform service.
27- #[ cfg( not( target_os = "linux" ) ) ]
31+ #[ cfg( not( any ( target_os = "linux" , target_os = "windows" ) ) ) ]
2832pub struct CreatedShm {
2933 /// The owned shared-memory mapping.
3034 pub shm : Shm ,
@@ -35,11 +39,9 @@ pub struct CreatedShm {
3539/// # Errors
3640///
3741/// Returns an error if the platform cannot create or map the region.
38- #[ cfg( not( target_os = "linux" ) ) ]
42+ #[ cfg( not( any ( target_os = "linux" , target_os = "windows" ) ) ) ]
3943pub fn create ( size : usize ) -> io:: Result < CreatedShm > {
4044 let conf = ShmemConf :: new ( ) . size ( size) ;
41- #[ cfg( target_os = "windows" ) ]
42- let conf = conf. allow_raw ( true ) ;
4345
4446 let inner = conf. create ( ) . map_err ( io:: Error :: other) ?;
4547 Ok ( CreatedShm { shm : Shm { inner } } )
@@ -50,17 +52,15 @@ pub fn create(size: usize) -> io::Result<CreatedShm> {
5052/// # Errors
5153///
5254/// Returns an error if the mapping does not exist or cannot be mapped.
53- #[ cfg( not( target_os = "linux" ) ) ]
55+ #[ cfg( not( any ( target_os = "linux" , target_os = "windows" ) ) ) ]
5456pub fn open ( id : & str , size : usize ) -> io:: Result < Shm > {
5557 let conf = ShmemConf :: new ( ) . size ( size) . os_id ( id) ;
56- #[ cfg( target_os = "windows" ) ]
57- let conf = conf. allow_raw ( true ) ;
5858
5959 let inner = conf. open ( ) . map_err ( io:: Error :: other) ?;
6060 Ok ( Shm { inner } )
6161}
6262
63- #[ cfg( not( target_os = "linux" ) ) ]
63+ #[ cfg( not( any ( target_os = "linux" , target_os = "windows" ) ) ) ]
6464#[ expect( clippy:: len_without_is_empty, reason = "shared-memory mappings are always non-empty" ) ]
6565impl Shm {
6666 /// Returns this mapping's opaque platform identifier.
0 commit comments