Skip to content

feat: add consistent raw pointer access across wrapper types#328

Open
revmischa wants to merge 1 commit into
masterfrom
feat/raw-pointer-access
Open

feat: add consistent raw pointer access across wrapper types#328
revmischa wants to merge 1 commit into
masterfrom
feat/raw-pointer-access

Conversation

@revmischa

@revmischa revmischa commented Feb 2, 2026

Copy link
Copy Markdown
Member

Addresses #326

Adds raw() and unsafe fn from_raw() to wrapper types that were missing them, so users can interop with raw SDL when needed.

Types updated: AudioStream, Joystick, Gamepad, Sensor, Haptic, Cursor, Palette, Texture, Sampler, FPSManager

Also:

  • AudioStreamWithCallback now implements Deref<Target=AudioStream> so all stream methods are accessible
  • Fixed Joystick::drop to always close (was skipping disconnected joysticks, leaking resources)
  • Added debug_assert null checks in from_raw() for easier debugging

Closes #326

@revmischa
revmischa force-pushed the feat/raw-pointer-access branch 2 times, most recently from 9db36f7 to 3081aad Compare February 2, 2026 05:59
Add `raw()` getters and `unsafe fn from_raw()` constructors to wrapper
types that were missing them, enabling users to interoperate with raw
SDL APIs when the safe abstractions don't cover their use case.

Changes:
- AudioStream: add raw(), from_raw(), deprecate stream()
- AudioStreamWithCallback: add Deref/DerefMut to expose AudioStream methods,
  remove redundant forwarding methods (now handled by Deref)
- Joystick, Gamepad, Sensor, Haptic, Cursor: add raw() and from_raw()
- Palette, Texture: add from_raw() (raw() already exists)
- Sampler: make raw() public (was private)
- FPSManager: add raw() and from_raw()

Safety improvements:
- Add debug_assert null checks to all from_raw() implementations
- Fix Joystick::drop to always call SDL_CloseJoystick (was conditional
  on connected() status, which could leak resources)

Closes #326

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@EriKWDev

EriKWDev commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

I also think there are a bunch of functions from_ll and to_ll

What is the reason for their names being _ll?

@revmischa

Copy link
Copy Markdown
Member Author

I also think there are a bunch of functions from_ll and to_ll

What is the reason for their names being _ll?

This was carried over from sdl2-rs. I assume it means low-level

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please always expose a way to construct a type unsafely or access the underlying private fields

3 participants