GithubHelp home page GithubHelp logo

drocdotcode / ceras Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rikimaru0345/ceras

0.0 0.0 0.0 802 KB

Universal binary serializer for a wide variety of scenarios https://discord.gg/FGaCX4c

Home Page: https://rikidev.com/

License: Apache License 2.0

C# 100.00%

ceras's Introduction

Ceras

AppVeyor Test Results LICENSE Discord

NuGet Release

Universal binary serializer for a wide variety of scenarios, lots of features, and tuned for performance

Ceras is a binary serializer. It converts whatever object you give it into a byte[] and back. It's not just a replacement for BinaryFormatter or MessagePack, it also adds tons of features on top.

Supports reference loops, large/complicated inheritance chains, splitting objects into parts, ...

Quick start

using Ceras;

class ExamplePerson { public string Name; public int Number; }
var p = new ExamplePerson { Name = "test", Number = 5 };

var s = new CerasSerializer();

var bytes = s.Serialize(p);

Features

Major Features

  • Very fast, very small binary output
  • Supports pretty much any type:
  • Full support for circular references (including object caching)
  • Full support for polymorphism / inheritance / interfaces
  • Can serialize objects into parts as "ExtenalObjects" (useful in many many scenarios)
  • Automatic version-tolerance, no need to assign any attributes to your classes!

What can this be used for?

Example usages

The primary goal is to make an universal serializer that can be used in every situation. Personally my primary intentions were easy object persistance and network communication. I've added many features over time and whenever someone can think of a good scenario that should be supported as well I'll make it happen.

Examples:

  • Settings: Saving objects to disk quickly without much trouble: settings, savegames, whatever it is. With pretty much zero config. See steps 1 and 2 in the Usage Guide

  • Splitting: So your Person has reference to other Person objects, but each one should be serialized individually? No problem, use IExternalRootObject. It's super easy. (see External Objects Guide (Game DB example))).

  • Network: In the past people used to manually write network messages into a network stream or packet because serialization was either too slow or couldn't handle complicated object-graphs. Receiving objects from the network also allocated a lot of 'garbage objects' because there was no easy way to recycle packets. Other serializers always write long type names... Ceras fixes all of this, with some simple setup you can implement a very efficient protocol (see Network Example Guide). If you want to, you can even let Ceras 'learn' types that get sent so types will be automatically encoded to short IDs (or use config.KnownTypes to register network types for maximum efficiency).

  • More: The above are just examples, Ceras is made so it can be used in pretty much every situation...

When should I not use this?

  • If you need human readable output for some reason. For example some file that you want to be able to edit in a text-editor. For those usages JSON or XML are likely better suited.

  • You plan to use this on a platform that does not support code generation. Serializers for user-types are created at runtime through code-generation. And if that isn't allowed (for example on iOS) Ceras won't be able to generate arbitrary object-formatters. Built-in types will still work though. There are ways to fix this though... (pre-generating the formatters)

Support

Want me to help you? These are your options:

ceras's People

Contributors

meiktranel avatar rikimaru0345 avatar

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.