Git Product home page Git Product logo

byte-array's Introduction

ByteArray

Version
A library that supports Java-like series processing. This is useful when you already know the format of your data. On the other hand, the processing of invalid data is relatively poor, so it is not recommended to use it for uncertain data.

Installation

[dependencies]
byte_array = "0.1"

Usage

use byte_array::ByteArray;

fn main() {

    // Create an empty ByteArray
    let mut ba = ByteArray::new();
    
    // Input data
    let a: f64      = 3.14;
    let b: u16      = 1234;
    let c: String   = String::from("hello");
    
    // Write data to ByteArray
    ba.write(&a);
    // ( Using Operator <<= )
    ba <<= &b;
    ba <<= &c;
    
    // Read data from ByteArray
    ba.seek_first();
    assert_eq!(a, ba.read::<f64>());                // 3.14
    assert_eq!(b, ba.read_safe::<u16>().unwrap());  // 1234
    assert_eq!(c, ba.read::<String>());             // "hello"
}

Supported Data Types

Data Type Supported
bool Yes
u8 Yes
u16 Yes
u32 Yes
u64 Yes
u128 Yes
i8 Yes
i16 Yes
i32 Yes
i64 Yes
i128 Yes
f32 Yes
f64 Yes
--------------- -----------
usize as u64 Yes
isize as i64 Yes
--------------- -----------
Vec Yes
String Yes
ByteArray Yes
User-Defined Optional

Documentation

Docs.rs

License

Distributed under MIT License since 2019.

byte-array's People

Contributors

hokim98 avatar pegesund avatar

Stargazers

 avatar

Forkers

pegesund

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.