-
Notifications
You must be signed in to change notification settings - Fork 11
Session3 data models p1 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
falyhery
wants to merge
6
commits into
holochain-devcamp:session3_data_models_p1
Choose a base branch
from
falyhery:session3_data_models_p1
base: session3_data_models_p1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f1e98c3
Entry defs added to lib.rs
falyhery c7c0d43
Create mod.rs in Section
falyhery ddb8c11
Add entry.rs to Section
falyhery bf0a405
Add anchor.rs to Section
falyhery 61c9c3d
Create mod.rs in Content
falyhery 0082d7d
Add entry.rs to Content
falyhery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| use hdk::{ | ||
| entry_definition::ValidatingEntryType, | ||
| holochain_core_types::{dna::entry_types::Sharing, validation::EntryValidationData}, | ||
| holochain_json_api::{error::JsonError, json::JsonString}, | ||
| holochain_persistence_api::cas::content::Address, | ||
| }; | ||
| use holochain_entry_utils::HolochainEntry; | ||
|
|
||
| #[derive(Serialize, Deserialize, Debug, DefaultJson, Clone)] | ||
| pub struct Content { | ||
| pub title: String, | ||
| pub timestamp: u64, | ||
| pub anchor_address: Address, | ||
| } | ||
|
|
||
| impl Content { | ||
| pub fn new( | ||
| title: String, | ||
| timestamp: u64, | ||
| anchor_address: Address, | ||
| ) -> Self { | ||
| title: title, | ||
| timestamp: timestamp, | ||
| anchor_address: anchor_address, | ||
| } | ||
| } | ||
|
|
||
| impl HolochainEntry for Content { | ||
| fn entry_type() -> String { | ||
| String::from("section") | ||
|
falyhery marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
| // Holochain entry definition for Content | ||
| pub fn content_entry_def() -> ValidatingEntryType { | ||
| entry!( | ||
| name: Content::entry_type(), | ||
| description: "this is the definition of content", | ||
| sharing: Sharing::Public, | ||
| validation_package: || { | ||
| hdk::ValidationPackageDefinition::Entry | ||
| }, | ||
| validation: | validation_data: hdk::EntryValidationData<Content>| { | ||
| match validation_data { | ||
| EntryValidationData::Create { .. } => { | ||
| Ok(()) | ||
| }, | ||
| EntryValidationData::Modify { .. } => { | ||
| Ok(()) | ||
| }, | ||
| EntryValidationData::Delete { .. } => { | ||
| Ok(()) | ||
| } | ||
| } | ||
| }, | ||
| links: [] | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| pub mod entry; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #[derive(Serialize, Deserialize, Debug,self::DefaultJson, Clone)] | ||
| pub struct SectionAnchor { | ||
|
falyhery marked this conversation as resolved.
|
||
| pub title: String, | ||
| pub timestamp: u64, | ||
| } | ||
|
|
||
| impl AnchorTrait for SectionAnchor { | ||
| fn entry_type() -> String { | ||
| String::from("section_anchor") | ||
| } | ||
| fn link_to() -> String { | ||
| Section::entry_type() | ||
| } | ||
| fn link_type() -> String { | ||
| "section_anchor->section".to_owned() | ||
| } | ||
| } | ||
|
|
||
| impl SectionAnchor { | ||
| pub fn new(title: String, timestamp: u64) -> Self { | ||
| SectionAnchor { | ||
| title:title, | ||
| timestamp: timestamp, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| pub fn section_anchor_def() -> ValidatingEntryType { | ||
| entry!( | ||
| name: SectionAnchor::entry_type(), | ||
| sharing: Sharing::Public, | ||
| validation_package: || { | ||
| hdk::ValidationPackageDefinition::Entry | ||
| }, | ||
| validation: | validation_data: hdk::EntryValidationData<SectionAnchor>| { | ||
| match validation_data{ | ||
| EntryValidationData::Create { .. } => { | ||
| Ok(()) | ||
| }, | ||
| EntryValidationData::Modify { .. } => { | ||
| Ok(()) | ||
| }, | ||
| EntryValidationData::Delete { .. } => { | ||
| Ok(()) | ||
| } | ||
| } | ||
| }, | ||
| links:[ | ||
|
falyhery marked this conversation as resolved.
|
||
| // link that connects SectionAnchor to the latest Section entry | ||
| to!( | ||
| SectionAnchor::link_to(), | ||
| link_type: SectionAnchor::link_type(), | ||
| validation_package:||{ | ||
| hdk::ValidationPackageDefinition::Entry | ||
| }, | ||
| validation:|_validation_data: hdk::LinkValidationData|{ | ||
| Ok(()) | ||
| } | ||
| ) | ||
| ] | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| use hdk::{ | ||
| entry_definition::ValidatingEntryType, | ||
| holochain_core_types::{dna::entry_types::Sharing, validation::EntryValidationData}, | ||
| holochain_json_api::{error::JsonError, json::JsonString}, | ||
| holochain_persistence_api::cas::content::Address, | ||
| }; | ||
| use holochain_entry_utils::HolochainEntry; | ||
|
|
||
| #[derive(Serialize, Deserialize, Debug, DefaultJson, Clone)] | ||
| pub struct Section { | ||
|
falyhery marked this conversation as resolved.
|
||
| pub title: String, | ||
| pub timestamp: u64, | ||
| pub anchor_address: Address, | ||
| } | ||
|
|
||
| impl Section { | ||
| pub fn new( | ||
| title: String, | ||
| timestamp: u64, | ||
| anchor_address: Address, | ||
| ) -> Self { | ||
| title: title, | ||
| timestamp: timestamp, | ||
| anchor_address: anchor_address, | ||
| } | ||
| } | ||
|
|
||
| impl HolochainEntry for Section { | ||
| fn entry_type() -> String { | ||
| String::from("course") | ||
|
falyhery marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
| // Holochain entry definition for Section | ||
| pub fn section_entry_def() -> ValidatingEntryType { | ||
| entry!( | ||
| name: Section::entry_type(), | ||
| sharing: Sharing::Public, | ||
| validation_package: || { | ||
| hdk::ValidationPackageDefinition::Entry | ||
| }, | ||
| validation: | validation_data: hdk::EntryValidationData<Section>| { | ||
| match validation_data { | ||
| EntryValidationData::Create { .. } => { | ||
| Ok(()) | ||
| }, | ||
| EntryValidationData::Modify { .. } => { | ||
| Ok(()) | ||
| }, | ||
| EntryValidationData::Delete { .. } => { | ||
| Ok(()) | ||
| } | ||
| } | ||
| }, | ||
| links: [] | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| pub mod anchor; | ||
| pub mod entry; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.