Skip to content

docs: document ownership contract for GpmSample raw handle APIs - #143

Merged
brayniac merged 1 commit into
rust-nvml:mainfrom
brayniac:docs/gpm-handle-safety
Aug 10, 2026
Merged

docs: document ownership contract for GpmSample raw handle APIs#143
brayniac merged 1 commit into
rust-nvml:mainfrom
brayniac:docs/gpm-handle-safety

Conversation

@brayniac

Copy link
Copy Markdown
Contributor

Follow-up to #141.

  • Expand the # Safety docs on GpmSample::from_handle to spell out the full contract: the handle must come from nvmlGpmSampleAlloc on the same loaded NVML library, must not already be freed, and nothing else may free it afterward (double-free hazard).
  • Clarify in handle()'s docs that the returned handle is borrowed and cross-link the related APIs.
  • Add GpmSample::into_handle() as an explicit ownership-transfer path, so the handle() + mem::forget dance isn't needed to round-trip a sample through from_handle.

🤖 Generated with Claude Code

https://claude.ai/code/session_012YY5qSm6ERJ4gheYggH22M

Expand the safety docs on from_handle to spell out the full contract
(handle provenance and the double-free hazard), clarify that handle()
returns a borrowed handle, and add into_handle() as an explicit
ownership-transfer path that doesn't require callers to mem::forget
the wrapper themselves.

Follow-up to rust-nvml#141.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012YY5qSm6ERJ4gheYggH22M
@brayniac
brayniac merged commit 0aebd96 into rust-nvml:main Aug 10, 2026
7 checks passed
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.

1 participant