Skip to content
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

code organizing #368

Open
wants to merge 1 commit into
base: sprout
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions zomes/rea_plan/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ pub use vf_attributes_hdk::{

//---------------- EXTERNAL RECORD STRUCTURE ----------------

/// I/O struct utilized to read back a single record
/// specified by its hash/address.
///
#[derive(Debug, Serialize, Deserialize)]
struct ReadParams {
pub address: PlanAddress,
}

/// I/O struct to describe the complete record, including all managed link fields
///
#[derive(Clone, Serialize, Deserialize, SerializedBytes, Debug)]
Expand Down Expand Up @@ -59,6 +67,16 @@ pub struct ResponseData {

//---------------- CREATE REQUEST ----------------

/// I/O struct to describe what is passed in from outside the gateway to create a Plan.
/// This is structured as-is with named attributes in order to leave space
/// for future additional input values.
///
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct CreateParams {
pub plan: CreateRequest,
}

/// I/O struct to describe the complete input record, including all managed links
///
#[derive(Clone, Serialize, Deserialize, SerializedBytes, Debug)]
Expand Down Expand Up @@ -91,6 +109,15 @@ impl<'a> CreateRequest {

//---------------- UPDATE REQUEST ----------------

/// I/O struct to describe what is passed in from outside the gateway to update a Plan.
/// This is structured as-is with named attributes in order to leave space
/// for future additional input values.
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct UpdateParams {
pub plan: UpdateRequest,
}

/// I/O struct to describe the complete input record, including all managed links
///
#[derive(Clone, Serialize, Deserialize, SerializedBytes, Debug)]
Expand Down
17 changes: 0 additions & 17 deletions zomes/rea_plan/zome/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,11 @@ use hdk::prelude::*;
use hc_zome_rea_plan_rpc::*;
use hc_zome_rea_plan_lib::*;

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct CreateParams {
pub plan: CreateRequest,
}

#[hdk_extern]
fn create_plan(CreateParams { plan }: CreateParams) -> ExternResult<ResponseData> {
Ok(handle_create_plan(PLAN_ENTRY_TYPE, plan)?)
}

#[derive(Debug, Serialize, Deserialize)]
struct ReadParams {
pub address: PlanAddress,
}

#[hdk_extern]
fn get_plan(ReadParams { address }: ReadParams) -> ExternResult<ResponseData> {
Ok(handle_get_plan(address)?)
Expand All @@ -38,12 +27,6 @@ fn get_revision(ByRevision { revision_id }: ByRevision) -> ExternResult<Response
Ok(handle_get_revision(revision_id)?)
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct UpdateParams {
pub plan: UpdateRequest,
}

#[hdk_extern]
fn update_plan(UpdateParams { plan }: UpdateParams) -> ExternResult<ResponseData> {
Ok(handle_update_plan(plan)?)
Expand Down