https://github.com/ojford/recfiles-rs
Manage GNU Recfiles from rust
https://github.com/ojford/recfiles-rs
database flat-file human-readable plaintext recfiles rust
Last synced: 7 months ago
JSON representation
Manage GNU Recfiles from rust
- Host: GitHub
- URL: https://github.com/ojford/recfiles-rs
- Owner: OJFord
- Created: 2020-03-15T20:23:21.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-15T23:23:12.000Z (over 5 years ago)
- Last Synced: 2025-03-19T01:45:23.884Z (7 months ago)
- Topics: database, flat-file, human-readable, plaintext, recfiles, rust
- Language: Rust
- Size: 16.6 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# [recfiles](https://crates.io/crates/recfiles) & [serde_rec](https://crates.io/crates/serde_rec)
Manage GNU Recfiles from rust.
[](https://crates.io/crates/recfiles) [](https://crates.io/crates/serde_rec)
## Installation
`recfiles` (in-memory recfile handling) & `serde_rec` (data format for serde) on [crates.io](https://crates.io).
## Usage
```rust
use recfiles::Record;
use serde_rec::to_string;#[derive(Default, Serialize)]
#[serde(rename_all="PascalCase")]
struct Book {
author: Vec,
title: String,
publisher: Option,
}impl Record for Book {}
let book = Book {
author: vec![String::from("A.E.J. Eliott, OBE")],
title: String::from("Thirty Days in the Samarkind Desert with the Duchess of Kent"),
..Default::default()
}let serialised = to_string(&book).unwrap();
assert_eq!(serialised, textwrap::dedent("
Author: A.E.J. Eliott, OBE
Title: Thirty Days in the Samarking Desert with the Duchess of Kent");
```We can also specify the record descriptor for 'Book':
```rust
let book_descriptor = recfiles::Descriptor {
name: String::from("Book"),
key: vec![String::from("Title")],
allowed: vec![String::from("Publisher"),
}
```And serialise a full record set:
```rust
let rs = recfiles::RecordSet {
descriptor: Some(book_descriptor),
records: vec![book],
}serde_rec::to_string(&rs);
```## Work in progress
This is a work in progress, and currently incomplete & poorly documented.
(As of writing, the above's all you're getting :wink:.)
### Coming...
* Deserialisation
* Deriving descriptors
* File (rather than just to/from string) helpers
* In-memory (not shelling out to `recutils`) querying helpers
* Docs!