Commit Graph

13 Commits

Author SHA1 Message Date
Tobin C. Harding ba1166a63b
Make crate level attributes uniform
Make the trait level attributes uniform across all released crates in
the repo. Excludes things that are obviously not needed, eg, bench stuff
if there is not bench code.

- Remove `uninhabited_references` - this is allow by default now.
- Remove `unconditional_recursion` and mark the single false positive we
  have with an `allow`.

Note, this does not add `missing_docs` to the `io` crate. There is an
open PR at the moment to add that along with the required docs.
2024-01-31 11:32:46 +11:00
Martin Habovstiak 7c3b198127 Add a simple `Copy`-able `ArrayVec`
The `arrayvec::ArrayVec` type is not `Copy` which is not nice and we
would like to have a `Copy` type in our crates. While the PR to add
support to the `arrayvec` crate is not merged we implement our own
simplified version.

This one acts mostly as a dumb storage - it has just a few methods and
traits. The new ones can be added as needed later.
2023-12-15 01:37:53 +01:00
Martin Habovstiak f17c0402b7 Add tools that help with making code `const`
There are various challenges when making code `const`: making it
conditional, awkward copying of slices... This change adds tools that
help dealing with these challenges.
2023-12-15 01:37:33 +01:00
Steven Roose 875545517d
Add clippy exceptions for needless_question_mark lint 2023-10-23 16:45:52 +01:00
Tobin C. Harding bb8bd16302
internals: Remove hex module
Remove the now unused `hex` module from internals, this functionality is
now provided by the `hex-conservative` crate.
2023-07-21 10:59:47 +10:00
Martin Habovstiak 2b6bcf085c Implement support for `alloc`-free parse errors
This implements basic facilities to conditionally carry string inputs in
parse errors. This includes:

* `InputString` type that may carry the input and format it
* `parse_error_type!` macro creating a special type for parse errors
* `impl_parse` implementing parsing for various types as well as its
  `serde`-supporting alternative
2023-06-04 21:15:37 +02:00
Tobin C. Harding 1c3bbd4bf2
internals: Remove attribution from all files
As we did for the `bitcoin` crate, remove attribution from all files in
the `internals` crate.

While we are at it add an SPDX line to the few files missing it, whether
this license nonsense is even needed is left as an argument for another
day.

Justification:

Currently we have a mishmash of attribution lines accompanying the SPDX
identifier. These lines are basically meaningless because:

    - The date is often wrong
    - The original author attributed is not the only contributor to a file
    - The term "rust bitcoin developers" is basically just noise

Just remove all the attribution lines and be done with it.
2023-05-01 09:31:42 +10:00
Tobin C. Harding a189942c64
Use doc_auto_cfg
If we use `#![cfg_attr(docsrs, feature(doc_auto_cfg))]` instead of
`#![cfg_attr(docsrs, feature(doc_cfg))]` we no longer need to manually
mark types with `#[cfg_attr(docsrs, doc(cfg(feature = "std")))]`.

Sweeeeeet.
2023-03-29 14:50:33 +11:00
Harshil Jani a1c3082319 Move deny lint checks to script
Signed-off-by: Harshil Jani <harshiljani2002@gmail.com>
2023-02-14 10:48:24 +05:30
Tobin C. Harding 771cdde282 Move impl_array_newtype to bitcoin_internals
`impl_array_newtype` is an internal macro, move it to a new, ever so
meaningfully named, `macros` module.

Use `#[macro_export]`, no other changes to the macro.
2022-10-20 06:14:59 +11:00
Martin Habovstiak 1bf885550e Redesign `hex::BufEncoder` to accept owned arrays
Not being able to create an owned `BufEncoder` prevented returning it
from functions which need to allocate the buffer on stack. Such is the
case in WIP serde via consensus serialzation.

This change refactors `OutBytes` to be unsized, adds an `AsOutBytes`
trait and uses that one instead of `Into` to perform the conversion.
2022-09-14 19:41:58 +02:00
Martin Habovstiak 040b14ef1a Implement basic support for fast hex encoding
There's a `hex` module in `bitcoin_hashes` which is a bit out of place
and not very fast - it passes each *digit* through dynamic dispatch not
only adding overhead but also not allowing `String` to make better
allocations.

This change adds basic support for hex encoding using a stack-allocated
buffer which minimizes the overhead of dynamic dispatch. It also
provides a new `DisplayHex` trait designed to replace `ToHex` found in
`bitcoin_hashes`.
2022-09-13 22:17:31 +02:00
Tobin C. Harding 834bbf461f Introduce bitcoin-internals crate
Add a new crate `bitcoin-internals` to be used for internal code needed
by multiple soon-to-be-created crates.

Add the `write_err` macro to `bitcoin-internals`, nothing else.

This patch uses a `path` dependency which means `rust-bitcoin` cannot be
released in its current state, will need to be changed once we release
the `bitcoin-internals` crate on `crates.io`.
2022-09-13 08:59:57 +10:00