Coder Social home page Coder Social logo

lemon-mint / vstruct Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 1.0 25.5 MB

Code Generation Based High Speed Data Serialization Tool

Home Page: https://vstruct.pages.dev

License: MIT License

Go 67.05% Rust 6.62% Dart 3.47% Shell 0.11% HTML 5.80% Python 5.43% JavaScript 1.48% TypeScript 5.31% C# 4.71%
serialization deserialization high-performance zerocopy vstruct golang go

vstruct's Introduction

GitHub GitHub tag (latest SemVer) npm

vstruct

Code Generation Based High Speed Data Serialization Tool

Installation

1. From NPM (recommended)

npm install -g vstruct

2. Go Get (Go Install) (also recommended)

go install github.com/lemon-mint/vstruct/cli/vstruct@latest

3. From Source

git clone https://github.com/lemon-mint/vstruct.git
cd vstruct
go build -o vstruct ./cli/vstruct

4. Pre-compiled binaries

https://github.com/lemon-mint/vstruct/releases/latest

Vstruct Syntax

0. Primitive Types

0.1. Boolean


bool: bool # true or false

0.2. Signed Integers


int8: int8 # signed 8-bit integer
int16: int16 # signed 16-bit integer
int32: int32 # signed 32-bit integer
int64: int64 # signed 64-bit integer

0.3. Unsigned Integers


uint8: uint8 # unsigned 8-bit integer
uint16: uint16 # unsigned 16-bit integer
uint32: uint32 # unsigned 32-bit integer
uint64: uint64 # unsigned 64-bit integer

0.4. Floating Point


float32: float32 # 32-bit floating point (IEEE 754)
float64: float64 # 64-bit floating point (IEEE 754)

0.5. Bytes


bytes: bytes # variable length bytes

0.6. String


string: string # variable length string

1. Enum

enum MyEnum {
    one,
    two,
    three
}

2. Struct

struct MyStruct {
    uint8  a;
    uint16 b;
    uint32 c;
    uint64 d;
    string e;
    MyEnum f;
}

3. Alias

alias UUID = string;

Vstruct CLI Usage

vstruct [options] <lang> <package name> <input file>

Options

-o <output> Output file name (default: <inputfile>.<.go|.py|.dart|.rs>)
-s          Prints the generated code to stdout
-v          Print version and exit
-h          Print help and exit
-l          Print license and exit

Languages

go: Go
python: Python
dart: Dart
rust: Rust (Experimental)

vstruct's People

Contributors

lemon-mint avatar renovate[bot] avatar snowmerak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

snowmerak

vstruct's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/release.yml
  • actions/checkout v3
  • actions/setup-go v3
  • goreleaser/goreleaser-action v3
  • actions/checkout v3
  • actions/setup-node v3
gomod
go.mod
  • go 1.18
npm
package.json
  • got 12.1.0
  • octokit 2.0.4
  • tar-fs 2.1.1
pub
_out/pubspec.yaml
  • primitive ^2.1.0
  • lints ^2.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

cannot find Byes type in generated rust code

source :

struct Frame {
    uint32 Service;
    uint32 Method;
    uint32 Sequence;
    uint32 BodySize;
    bytes Body;
}

result:

struct Frame {
    buffer: Vec<u8>,
}

impl Frame {
    ...

    pub fn Body(&self) -> Bytes {
        let __off0: u64 = 24;
        let __off1: u64 = self.buffer[16] as u64 
            | (self.buffer[17] as u64) << 8 
            | (self.buffer[18] as u64) << 16 
            | (self.buffer[19] as u64) << 24 
            | (self.buffer[20] as u64) << 32 
            | (self.buffer[21] as u64) << 40 
            | (self.buffer[22] as u64) << 48 
            | (self.buffer[23] as u64) << 56;
        // TODO: Think about rust's borrowing rules

        self.buffer[__off0 as usize..__off1 as usize].to_vec()
    }
}

Frame struct is not public and Bytes of pub fn Body(&self) -> Bytes is not found.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.