Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit 9cea16f

Browse files
author
Raphael Santo Domingo
committed
Add rust native implementation of protobufs
Other changes - Removed enum ProductType declarations in each Product action message (see protos/product_payload.proto) - Renamed 'product_values' field to 'properties' field for coherency (see protos/product_state.proto) - Renamed 'type' field to 'product_type' because 'type' is a reserved key word - Renamed 'identifier field to 'product_id' field because 'identifier' is a rust error descriptor - Replaced deprecated StdError 'cause' function with new 'source' function (see protocol/product/state.rs) Signed-off-by: Raphael Santo Domingo <[email protected]>
1 parent b7ec9a4 commit 9cea16f

File tree

6 files changed

+1359
-26
lines changed

6 files changed

+1359
-26
lines changed

sdk/protos/product_payload.proto

+10-22
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,24 @@ message ProductPayload {
3737
}
3838

3939
message ProductCreateAction {
40-
enum ProductType {
41-
UNSET_TYPE = 0;
42-
GS1 = 1;
43-
}
44-
// product_type and identifier are used in deriving the state address
45-
ProductType product_type = 1;
46-
string identifier = 2;
40+
// product_type and product_id are used in deriving the state address
41+
Product.ProductType product_type = 1;
42+
string product_id = 2;
4743
string owner = 3;
4844
repeated PropertyValue properties = 4;
4945
}
5046

5147
message ProductUpdateAction {
52-
enum ProductType {
53-
UNSET_TYPE = 0;
54-
GS1 = 1;
55-
}
56-
// product_type and identifier are used in deriving the state address
57-
ProductType product_type = 1;
58-
string identifier = 2;
48+
// product_type and product_id are used in deriving the state address
49+
Product.ProductType product_type = 1;
50+
string product_id = 2;
5951
// this will replace all properties currently defined
60-
repeated PropertyValue properties = 4;
52+
repeated PropertyValue properties = 3;
6153
}
6254

6355
message ProductDeleteAction {
64-
enum ProductType {
65-
UNSET_TYPE = 0;
66-
GS1 = 1;
67-
}
68-
// product_type and identifier are used in deriving the state address
69-
ProductType product_type = 1;
70-
string identifier = 2;
56+
// product_type and product_id are used in deriving the state address
57+
Product.ProductType product_type = 1;
58+
string product_id = 2;
7159
}
7260

sdk/protos/product_state.proto

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ message Product {
2222
GS1 = 1;
2323
}
2424

25-
// Identifier for products (gtin)
26-
string identifier = 1;
25+
// product_id for products (gtin)
26+
string product_id = 1;
2727

2828
// What type of product is this (GS1)
29-
ProductType type = 2;
29+
ProductType product_type = 2;
3030

3131
// Who owns this product (pike organization id)
3232
string owner = 3;
3333

3434
// Addition attributes for custom configurations
35-
repeated PropertyValue product_values = 4;
35+
repeated PropertyValue properties = 4;
3636
}
3737

3838
message ProductList {

sdk/src/protocol/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414

1515
pub mod errors;
1616
pub mod pike;
17+
pub mod product;
1718
pub mod schema;
1819
pub mod track_and_trace;

sdk/src/protocol/product/mod.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2019 Target Brands, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
use super::errors;
16+
17+
pub mod payload;
18+
pub mod state;

0 commit comments

Comments
 (0)