Skip to content

Buffer filling APIs#129

Merged
swlynch99 merged 1 commit intorust-nvml:mainfrom
FreeMasen:fix/buffer-counts
Mar 5, 2026
Merged

Buffer filling APIs#129
swlynch99 merged 1 commit intorust-nvml:mainfrom
FreeMasen:fix/buffer-counts

Conversation

@FreeMasen
Copy link
Contributor

For any API that the docs indicate should be called twice, first to populate an in/out variable to calculate the buffer size needed to complete the second call which will fill the buffer, this PR will account for the potential for the first call to return nvmlReturn_enum_NVML_ERROR_INSUFFICIENT_SIZE (7) as is allowed by the docs.

To achieve this I've moved the conversion from nvmlReturn_t to NvmlError to an impl From and added a second version of the nvml_try which will consider both 0 and 7 success cases.

I attempted to find all cases where the pattern exists today and update those with this new nvml_try_count in stead of either the manual match statements or lack there of.

please let me know if there is a different way you'd like this problem solved

Closes #127

… a buffer and then to fill that buffer should now be accounted for
@FreeMasen FreeMasen mentioned this pull request Mar 5, 2026
@swlynch99
Copy link
Contributor

This looks good to me! Thanks for the fix!

@swlynch99 swlynch99 merged commit 29f91b8 into rust-nvml:main Mar 5, 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.

Calculating counts fails with InsufficientSize(None)

2 participants