StephanvanSchaik / mmap-rs

A cross-platform and safe Rust API to create and manage memory mappings in the virtual address space of the calling process.
Apache License 2.0
61 stars 17 forks source link

Tentative implementation of the TryFrom trait #44

Closed vigna closed 9 months ago

vigna commented 10 months ago

This is my first try. I decided to implement TryFrom rather than From, since all make methods return an error. Presently I have implemented conversions towards Mmap and MmapMut from Mmap, MmapMut and MmapNone. I have added a reference blurb to the documentation of the make methods.

How does that look?

Would it make sense to have these four TryFrom also for the Reserved* structs?

StephanvanSchaik commented 10 months ago

How does that look?

Re-using the the existing make_* functions to just take the Error out and drop the Mmap object looks good to me.

Would it make sense to have these four TryFrom also for the Reserved* structs?

Yes, that would make it complete and consistent.

vigna commented 10 months ago

I added the remaining TryFrom. I also converted a few existing TryInto into TryFrom, because the latter is more generic (there's a blanket for TryInto).

vigna commented 9 months ago

Hey, would you be so kind to make a release? We have a bunch of interconnected crates depending on this and it's a bit of a nightmare now :).

StephanvanSchaik commented 9 months ago

Sure! Let me look at fixing some minor issues (e.g. FreeBSD CI and the MSRV PR) and then I will prepare a release that incorporates this PR.