Skip to content

kasefuchs/chromium-pickle-dart

Repository files navigation

Chromium Pickle Dart

Status GitHub Issues GitHub Pull Requests GitHub Stars License


This library ports Chromium's Pickle class to Dart.

📝 Table of Contents

🧐 About

This library provides facilities for basic binary value packing and unpacking.

The Pickle class supports appending primitive values (ints, strings, etc.) to a pickle instance. The Pickle instance grows its internal memory buffer dynamically to hold the sequence of primitive values. The internal memory buffer is exposed as the "data" of the Pickle. This "data" can be passed to a Pickle object to initialize it for reading.

When reading from a Pickle object, it is important for the consumer to know what value types to read and in what order to read them as the Pickle does not keep track of the type of data written to it.

The Pickle's data has a header which contains the size of the Pickle's payload.

🏁 Getting Started

Prerequisites

This library doesn't have many requirements, so here's what you need:

Dart SDK >=2.18.0

Installing

Just run it and now you're ready to rock

dart pub add chromium_pickle

🎈 Usage

Here is a basic application using pickles

import 'package:chromium_pickle/chromium_pickle.dart';

void main() {
  // Create empty pickle
  var pickle = Pickle.empty();

  // Write value to pickle
  pickle.writeInt(25565);

  // Create iterator
  var iterator = pickle.createIterator();

  // Print current pickle value
  print(iterator.readInt());

  // Print buffer content
  print(buffer.toUint8List());
}

⛏️ Built Using

🎉 Acknowledgements