You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: extract NativeStr into standalone crate (#338)
## Summary
- Extract `NativeStr` from `fspy_shared::ipc::native_str` into a new
`native_str` crate
- Re-exported from `fspy_shared::ipc` so all downstream crates are
unaffected
- New crate has minimal dependencies: `allocator-api2`, `bytemuck`,
`wincode`
- Includes README.md documenting the type's purpose and platform
behavior
## Test plan
- [x] `cargo clippy` passes
- [x] `cargo test --workspace --exclude fspy` passes
- [x] `cargo shear` reports no new unused deps
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
A platform-native string type for lossless, zero-copy IPC.
4
+
5
+
`NativeStr` is a `#[repr(transparent)]` newtype over `[u8]` that represents OS strings in their native encoding:
6
+
7
+
-**Unix**: raw bytes (same as `OsStr`)
8
+
-**Windows**: raw wide character bytes (from `&[u16]`, stored as `&[u8]` for uniform handling)
9
+
10
+
## Why not `OsStr`?
11
+
12
+
`OsStr` requires valid UTF-8 for serialization. `NativeStr` can be serialized/deserialized losslessly regardless of encoding, with zero-copy support via wincode's `SchemaRead`.
13
+
14
+
## Limitations
15
+
16
+
**Not portable across platforms.** The binary representation of a `NativeStr` is platform-specific — Unix uses raw bytes while Windows uses wide character pairs. Deserializing a `NativeStr` that was serialized on a different platform leads to unspecified behavior (garbage data), but is not unsafe.
17
+
18
+
This type is designed for same-platform IPC (e.g., shared memory between a parent process and its children), not for cross-platform data exchange or persistent storage. For portable paths, use UTF-8 strings instead.
0 commit comments