Skip to content

Add parse functions for large integer types. #11

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

Merged
merged 4 commits into from
Sep 15, 2022
Merged

Add parse functions for large integer types. #11

merged 4 commits into from
Sep 15, 2022

Conversation

DRiKE
Copy link
Contributor

@DRiKE DRiKE commented Sep 12, 2022

For routecore we need these three things. If we agree this should be in octseq, I'll add tests. Perhaps the IpAddr parsers can be in bit more efficient.

@partim
Copy link
Member

partim commented Sep 12, 2022

No arguments on u64 – maybe also add u128.

The methods for the IP address types, at the very least need to be feature gated against std. But maybe it would be better to bring back the Parse trait and let routecore impl it as needed? (This won’t work because of the foreign types and traits rules. I still think this should be in routecore for reasons of, er, purity? Maybe routecore can just define two functions and be done with it?)

That said, I think we should also add fn parse_array<N: const usize>(&self) -> Result<[u8; N], ShortInput>. That would make implementing the addresses much easier, as they both impl a From<[u8; _]>.

@partim partim changed the title Add parse functions for u64, Ipv4Addr and Ipv6Addr Add parse functions for large integer types. Sep 15, 2022
@partim partim merged commit 55e9a00 into main Sep 15, 2022
@partim partim deleted the ipaddr-parse branch September 15, 2022 08:37
partim added a commit that referenced this pull request May 12, 2023
Breaking Changes

* Drop the `OctetsRef` trait and introduce a new `Octets` trait that takes
  over its purpose. This requires Rust 1.65.0. ([#12])
* Change the signature of `Octets::range` to use a range and drop all the
  convenience methods. ([#13])
* Split conversion from an octets builder to an immutable octets sequence
  off of `OctetsBuilder` to the new `FreezeBuilder` trait. ([#25])
* Dropped the `len` and `is_empty` methods from the `OctetsBuilder` trait.
  These can be requested via `AsRef<[u8]>` if necessary. ([#20])
* Rearranged module structure:
  * broke up `traits` into `octets` and `builder`,
  * renamed `types` to `array`, and
  * moved `SmallOctets` to `octets`. ([#18])
* The integer parsing methods on `Parser` have been renamed to make it
  clear they parse big-endian integers and new methods for parsing
  little-endian integers have been added. ([#35])
* The optional traits `SerializeOctets` and `DeserializeOctets` have been
  redesigned for greater flexibility. ([#21])

New

* Added `Parser::parse_parser` that allows parsing a given number of octets
  and return them as a cloned parser. ([#10])
* Add methods to `Parser` to parse 64 and 128 bit integers. ([#11])
* Added support for the `heapless` crate. ([#19])
* Added missing `Octets` implementation for `Array<N>`. ([#29])
* Added `Octets` implementation for `Arc<[u8]>`. ([#28])
* Added blanket implementations for `OctetsBuilder` and `Truncate` for
  mutable references of types that are `OctetsBuilder` and `Truncate`,
  respectively. ([#30])
* Added conversions from `&str` and `&[u8]` to `Str<[u8]>`. ([#31])
* Added `Array::resize_raw`. ([#32], [#33])
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.

2 participants