Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation #32

Open
1 of 15 tasks
joshlf opened this issue Oct 7, 2022 · 3 comments
Open
1 of 15 tasks

Improve documentation #32

joshlf opened this issue Oct 7, 2022 · 3 comments
Labels
compatibility-nonbreaking Changes that are (likely to be) non-breaking

Comments

@joshlf
Copy link
Member

joshlf commented Oct 7, 2022

This issue tracks improvements to our documentation. See our roadmap for the high-level vision that the tasks tracked here fit into.

Top-level docs

Framing

  • Documentation frames zerocopy as a general-purpose tool for replacing unsafe code, not just as a tool for parsing or another specific task. Done in #386.
  • Consider adding examples of domains in which zerocopy is used in order to convey the breadth of use cases and suggest that it's not primarily meant for any single use case

Use cases

  • Top-level documentation points users in the right direction for most common use cases
    • This documentation must not assume a familiarity with unsafe code, but should instead focus on use cases

Correctness and soundness

  • Documentation frames the "unsafe as the cryptography of the Rust world" idea
  • Documentation describes zerocopy's future-soundness guarantee
  • Documentation describes the steps we take to ensure soundness
    • Safety/soundness arguments, especially with regards to reasoning only in terms of documented guarantees by the language reference or the standard library documentation
    • All tests run under Miri, including under experimental memory models (currently: stacked borrows, tree borrows, and strict provenance)
    • Once we use them, mention formal modeling tools (#378)
  • Consider citing high-profile users who are comfortable with this

Module/item docs

  • Items (types, methods, etc) provide toy examples to demonstrate basic usage
  • Modules and items whose usage is not self-evident provide more involved examples that help to teach users the correct mental model
  • Modules and items call out common use cases that would be reasonable to solve using them
  • Modules and items call out common use cases that would not be reasonable to solve using them, but which it would be easy to mistakenly believe would be reasonable to solve using them (e.g., FromBytes for parsing without considering endiannness)

Miscellaneous

  • Fully-fledged implementation examples in a separate module or in the examples directory

@kupiakos has provided this writeup and offered that we can incorporate it into our docs; it includes a lot of good examples and explanations

@joshlf joshlf added the blocking-next-release This issue should be resolved before we release on crates.io label Oct 15, 2022
@joshlf joshlf changed the title Documentation should describe the broad view of zerocopy's use cases Improve documentation Oct 23, 2022
@joshlf joshlf mentioned this issue Oct 24, 2022
@tim-seoss
Copy link

Whilst this is a big task, a couple of examples1 would probably go a long way to helping newcomers to zerocopy.

At its very simplest, it could take the form of a series of links to other repositories, each of which shows usage zerocopy in a common/canonical way.

If you could point me to an example or any notes or other resources for packet serialisation I'd be happy to try and knock something up and crate a PR.

Footnotes

  1. OK, there are already a couple of examples, but they are two slight variants of the same code - one in src/byteorder.rs at line 33 and the other in src/lib.rs at line 1482, and the example is UDP packet parsing/deserialisation - there are no examples at all of the sort of overview of code flow which is suitable for serialisation e.g. packet assembly example with header+body+footer

@joshlf
Copy link
Member Author

joshlf commented Aug 1, 2023

Thanks for offering to help, @tim-seoss! I unfortunately don't have time to help with this right now, but I'll let you know when I do 🙂

@joshlf joshlf added the compatibility-nonbreaking Changes that are (likely to be) non-breaking label Aug 12, 2023
@joshlf joshlf removed the blocking-next-release This issue should be resolved before we release on crates.io label Sep 3, 2023
@joshlf
Copy link
Member Author

joshlf commented Sep 13, 2023

Hey @tim-seoss, still don't have a ton of time to devote to mentoring this, but I realized that I could at least point you to some locations that have a lot of zerocopy uses you could take a look at. If you're interested in writing these up, I'd suggest at least pinging this thread first to confirm that a given example uses a pattern/style we'd like to encourage.

These are both in Fuchsia; the latter is specifically a packet parsing/serializing library, so it's got a lot of more gnarly uses of zerocopy. I'd just use the search function to search for "zerocopy" or the names of individual types, and that'll be a good starting point.

jswrenn added a commit that referenced this issue Nov 30, 2023
This PR adds examples to most methods of `FromBytes`, and
separately documents `derive(FromBytes)`. Theoretical soundness
requirements are placed with trait documentation, and the details
of the derive's analysis is placed in the derive documentation.

This PR follows the pattern of #505.

Makes progress towards #32.
jswrenn added a commit that referenced this issue Nov 30, 2023
This PR adds examples to most methods of `FromBytes`, and
separately documents `derive(FromBytes)`. Theoretical soundness
requirements are placed with trait documentation, and the details
of the derive's analysis is placed in the derive documentation.

This PR follows the pattern of #505.

Makes progress towards #32.
jswrenn added a commit that referenced this issue Nov 30, 2023
This PR adds examples to most methods of `FromBytes`, and
separately documents `derive(FromBytes)`. Theoretical soundness
requirements are placed with trait documentation, and the details
of the derive's analysis is placed in the derive documentation.

This PR follows the pattern of #505.

Makes progress towards #32.
github-merge-queue bot pushed a commit that referenced this issue Nov 30, 2023
This PR adds examples to most methods of `FromBytes`, and
separately documents `derive(FromBytes)`. Theoretical soundness
requirements are placed with trait documentation, and the details
of the derive's analysis is placed in the derive documentation.

This PR follows the pattern of #505.

Makes progress towards #32.
jswrenn added a commit that referenced this issue Nov 30, 2023
This PR adds examples to most methods of `AsBytes`, and
separately documents `derive(AsBytes)`. Theoretical soundness
requirements are placed with trait documentation, and the details
of the derive's analysis is placed in the derive documentation.

This PR follows the pattern of #505.

Makes progress towards #32.
jswrenn added a commit that referenced this issue Nov 30, 2023
This PR adds examples to most methods of `AsBytes`, and
separately documents `derive(AsBytes)`. Theoretical soundness
requirements are placed with trait documentation, and the details
of the derive's analysis is placed in the derive documentation.

This PR follows the pattern of #505.

Makes progress towards #32.
jswrenn added a commit that referenced this issue Nov 30, 2023
This PR adds examples to most methods of `AsBytes`, and
separately documents `derive(AsBytes)`. Theoretical soundness
requirements are placed with trait documentation, and the details
of the derive's analysis is placed in the derive documentation.

This PR follows the pattern of #505.

Makes progress towards #32.
jswrenn added a commit that referenced this issue Nov 30, 2023
This PR adds examples to the documentation of `transmute!`,
`transmute_ref!` and `transmute_mut!`.

Makes progress towards #32.
github-merge-queue bot pushed a commit that referenced this issue Nov 30, 2023
This PR adds examples to the documentation of `transmute!`,
`transmute_ref!` and `transmute_mut!`.

Makes progress towards #32.
jswrenn added a commit that referenced this issue Nov 30, 2023
This PR adds examples to most methods of `AsBytes`, and
separately documents `derive(AsBytes)`. Theoretical soundness
requirements are placed with trait documentation, and the details
of the derive's analysis is placed in the derive documentation.

This PR follows the pattern of #505.

Makes progress towards #32.
jswrenn added a commit that referenced this issue Nov 30, 2023
This PR adds examples to most methods of `AsBytes`, and
separately documents `derive(AsBytes)`. Theoretical soundness
requirements are placed with trait documentation, and the details
of the derive's analysis is placed in the derive documentation.

This PR follows the pattern of #505.

Makes progress towards #32.
github-merge-queue bot pushed a commit that referenced this issue Nov 30, 2023
This PR adds examples to most methods of `AsBytes`, and
separately documents `derive(AsBytes)`. Theoretical soundness
requirements are placed with trait documentation, and the details
of the derive's analysis is placed in the derive documentation.

This PR follows the pattern of #505.

Makes progress towards #32.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility-nonbreaking Changes that are (likely to be) non-breaking
Projects
None yet
Development

No branches or pull requests

2 participants