https://github.com/polyphony-chat/ser_der
Newtypes for the der crate to allow for [serde](https://serde.rs) de-/serialization.
https://github.com/polyphony-chat/ser_der
Last synced: 12 months ago
JSON representation
Newtypes for the der crate to allow for [serde](https://serde.rs) de-/serialization.
- Host: GitHub
- URL: https://github.com/polyphony-chat/ser_der
- Owner: polyphony-chat
- License: mpl-2.0
- Archived: true
- Created: 2024-05-05T12:01:52.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-05T15:05:49.000Z (about 2 years ago)
- Last Synced: 2025-05-30T09:11:19.639Z (about 1 year ago)
- Language: Rust
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ser_der
Newtypes for the der crate to allow for [serde](https://serde.rs) de-/serialization.
## Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
ser_der = { version = "0", features = ["alloc"] } # Features should match the ones of the der crate
der = { version = "0", features = ["alloc"] }
serde = { version = "1", features = ["derive"] }
```
You can then use the newtypes offered by this crate to de-/serialize DER-encoded data structures using serde.
```rust
#[derive(serde::Serialize, serde::Deserialize)]
struct MyStruct {
#[serde(with = "ser_der::asn1::ia5_string")]
bits: ser_der::asn1::IA5String,
}
```
All newtypes implement `Deref`, `DerefMut`, `From<[Newtype]> for [Type]` and `From<[Type]> for [Newtype]` to the underlying `der` type.
## Types covered
- [x] IA5String
- [ ] DateTime
- [ ] Document
- [ ] Length
- [ ] Any
- [ ] BitString
- [ ] GeneralizedTime
- [ ] Header
- [ ] Int
- [ ] Length
- [ ] Null
- [ ] ObjectIdentifier
- [ ] OctetString
- [ ] PrintableString
- [ ] SequenceOf
- [ ] SetOf
- [ ] Tag
- [ ] TeletexString
- [ ] Uint
- [ ] UtcTime
## Upstreaming to `der`
This crate is a temporary solution until the `der` crate supports serde de-/serialization. The plan is to upstream the serde support to the [`der` crate](https://github.com/RustCrypto/formats/tree/master/der).