Skip to content

Commit

Permalink
Issue #45, Issue #46
Browse files Browse the repository at this point in the history
  • Loading branch information
dsietz committed Jun 30, 2024
1 parent 3ed3128 commit f9ef686
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 194 deletions.
6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scaffolding-core"
version = "1.0.1"
version = "2.0.0"
authors = ["dsietz <davidsietz@yahoo.com>"]
categories = ["data-structures","development-tools","rust-patterns"]
description = "A software development kit that provides the scaffolding for building applications and services using OOP."
Expand All @@ -24,10 +24,6 @@ maintenance = {status = "actively-developed"}
name = "scaffolding_core"
path = "src/lib.rs"

[features]
default = ["person"]
person = []

[dependencies]
chrono = "0.4.35"
regex = "1.10.5"
Expand Down
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ For software development teams who appreciate a kick-start to their object orien
---

## What's New
| :star: General Release |
| ------------------------------------------------------------------------------ |
| This crate is in `general release` and is treated as the initial release. |
We made the crate easier to implement and updated the documentation and the crate metadata.

**1.0.0**
+ [Bug - trait Scaffolding is not object safe](https://github.com/dsietz/scaffolding-core/issues/33)
**2.0.0**
+ [re-export dependent crates for ease of easier usability](https://github.com/dsietz/scaffolding-core/issues/45)
+ [Clean up](https://github.com/dsietz/scaffolding-core/issues/46)

## Usage

Expand All @@ -40,10 +39,6 @@ For software development teams who appreciate a kick-start to their object orien
extern crate scaffolding_core;

use scaffolding_core::*;
use scaffolding_macros::*;
use serde_derive::{Deserialize, Serialize};
// Required for scaffolding extended functionality (e.g.: addresses, metadata, notes, phonenumbers)
use std::collections::BTreeMap;
```
(2) Add Scaffolding attributes and apply the trait to a `struct`
```rust
Expand Down
63 changes: 63 additions & 0 deletions examples/person.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
extern crate scaffolding_core;

use scaffolding_core::*;

#[scaffolding_struct(
"addresses",
"email_addresses",
"metadata",
"notes",
"phone_numbers",
"tags"
)]
#[derive(
Clone,
Debug,
Deserialize,
Serialize,
Scaffolding,
ScaffoldingAddresses,
ScaffoldingEmailAddresses,
ScaffoldingNotes,
ScaffoldingPhoneNumbers,
ScaffoldingTags,
)]
struct Person {
first_name: String,
last_name: String,
}

impl Person {
#[scaffolding_fn(
"addresses",
"email_addresses",
"metadata",
"notes",
"phone_numbers",
"tags"
)]
fn new(first: String, last: String) -> Self {
Self {
first_name: first,
last_name: last,
}
}
fn full_name(&self) -> String {
format!("{}, {}", self.last_name, self.first_name)
}
}

fn main() {
let mut person = Person::new("John".to_string(), "Smith".to_string());

println!("My name is {}. My id is {}", person.full_name(), person.id);
println!("Serialized json ...");
println!("{}", person.serialize());

let doppelganger = Person::deserialized(person.serialize().as_bytes()).unwrap();
println!(
"I'm also named {} and my id is the same: {}",
doppelganger.full_name(),
doppelganger.id
);
}
Loading

0 comments on commit f9ef686

Please sign in to comment.