#const #error #sql #sqlstate

no-std sqlstate-inline

Memory efficient const-friendly types for SQLSTATE codes

3 releases

0.1.2 Dec 9, 2022
0.1.1 Dec 9, 2022
0.1.0 Dec 9, 2022

#1137 in Database interfaces

MPL-2.0 license

55KB
1K SLoC

sqlstate-inline - Efficient storage types for SQLSTATE code strings

Crates.io Documentation License Build Status

Usage

  1. Add the following to your Cargo.toml:
[dependencies]
sqlstate-inline = "0.1"
  1. Read the crate documentation

Functionality

SQLSTATE codes are 5 character ASCII strings that only use the characters A-Z and 0-9. This crate provides an SqlState type that is const constructible and only consumes 5 bytes of memory, providing niches, so that e.g. Option<SqlState> is also 5 bytes large. This type dereferences to str and can be converted to e.g. [u8; 5] for maximum flexibility. E.g. using a std::string::String instead allocates 5 bytes on the heap and use 24 bytes on the stack (on 64-bit architectures) which in comparison is quite wasteful.

Feature flags

  • std: disable this feature to use the crate in no_std environments.
  • serde: enable this feature to get serde (de-)serialization support for the provided data types.

Supported Rust versions

The minimum supported Rust toolchain version is Rust 1.60.0.

Currently tested up to version 1.66.0-nightly.

Stability

This crate follows semantic versioning.

License

Licensed under Mozilla Public License, Version 2.0 (LICENSE or https://www.mozilla.org/en-US/MPL/2.0/).

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above including compatibility with secondary licenses, as defined by the MPL.

Dependencies

~185KB