rust-wasm-prost
This repository is a simple code for checking crate 'prost' on WebAssembly (
prost
?
What is prost
is a Protocol Buffers implementation for the Rust Language. prost
generates simple, idiomatic Rust code from proto2
and proto3
files.
How to serialize/deserialize Protocol Buffers data?
- Byte Stream: Check
src/example_byte_stream.rs
andwww/example_byte_stream.ts
. - JSON: Check
src/example_json.rs
andwww/example_json.ts
.
Protocol Buffers Struct in Example
You can see in proto
folder.
Simple
syntax = "proto3";
package rust_wasm_prost.simple;
message Student {
string name = 1;
int32 age = 2;
float height = 3;
float weight = 4;
repeated int32 grades = 5;
}
Complex
syntax = "proto3";
package rust_wasm_prost.complex;
message FruitCondition {
repeated float brix = 1;
string origin = 2;
}
message VegetableCondition {
repeated string nutrients = 1;
string origin = 2;
}
message Item {
int32 unique_id = 1;
message Information {
string name = 1;
int32 count = 2;
enum Type {
FRUIT = 0;
VEGETABLE = 1;
}
Type type = 3;
}
Information information = 2;
oneof condition {
FruitCondition fruit_condition = 3;
VegetableCondition vegetable_condition = 4;
}
}
Requirements
Quick Start
Rust + WebAssembly
- Run this command inside the project directory:
wasm-pack build
WebAssembly with TypeScript
- Ensure that the local development server and its dependencies are installed by running this command within the
www
subdirectory:
npm install
- Run this command from within the
www
subdirectory:
npm run start
- Go to
http://localhost:8080/
Contact
You can contact me via e-mail (utilForever at gmail.com). I am always happy to answer questions or help with any issues you might have, and please be sure to share any additional work or your creations with me, I love seeing what other people are making.
License
The class is licensed under the MIT License:
Copyright Β© 2022 Chris Ohk.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.