Ceras

2025-12-07 0 170

Ceras

Ceras is a binary serializer. It converts any object into a byte[] and back.
It goes above and beyond in terms of features, speed, and comfort.
Supports reference loops, large/complicated inheritance chains, splitting objects into parts, …

Quick start

class Person { public string Name; public int Age; }
var p = new Person { Name = \"riki\", Age = 5 };

var ceras = new CerasSerializer();

var bytes = ceras.Serialize(p);
  1. >> Many more examples in the code tutorial
  2. >> Detailed guides for specific scenarios on my blog
  3. >> Read \’Optimization & Usage Pitfalls\’
  • >> Changelog v3.0 (rikidev.com/new-features-in-ceras-3-0-2)
  • >> New features in v4.0 (https://g*i*thu*b.com/rikimaru0345/Ceras/releases/tag/4.0)

Features

  • Very fast, small binary output (see Performance)
  • Supports pretty much any type:
    • Hand-written formatters for all common .NET types
    • Comes with formatters for all common Unity types
    • Generates new formatters at runtime for any new/user type
    • Very easy to extend and customize
  • Full support for reference persistence (including circular references!)
  • Full support for polymorphism / inheritance / interfaces
  • Can serialize objects into parts as \”ExtenalObjects\” (useful in many many scenarios)
  • Automatic version-tolerance, no need to place any attributes on your classes!
  • full feature list (and planned features)

Performance benchmarks

Ceras generally ranks at the top end of the performance spectrum, together with NetSerializer and MessagePack-CSharp.
To get an idea of how Ceras performs here are the preliminary benchmark results.
The resulting binary size is about the same as MessagePack-CSharp.

The shown results are obtained from this code and I encourage you to not only try it yourself, but to also provide feedback about scenarios you had good and bad results with.

Don\’t forget to tune the settings in SerializerConfig for your specific situation.
Using Ceras to read/write network packets might require different settings than, lets say, saving a settings-object to a file, or persisting items/spells/monsters in a game, or …

The project is still heavily work-in-progress, meaning that over time more optimizations will get implemented (your feedback is important here!).

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 references to other Person objects, but each one should be serialized individually!? (without the references quickly dragging in essentially your whole program).
    Maybe you want to be able to put each Person into its own file, or send them over the network one-by-one as needed?
    No problem! Using IExternalRootObject it\’s not an issue! See External Objects Guide (Game DB example)).

  • Network:
    Because of its simple API and vast set of features Ceras is uniquely suited to implement a full \’network-protocol\’ for you.
    I wrote a short guide that shows off how a basic TCP implementation could look like:
    Just Send(myObject); it, then var obj = await Receive(); on the other side, that\’s it! It literally can\’t get any easier than that.
    At the moment the guide only has 2 parts, but when I have some (and if there are requests for it) I\’d like to continue the series, eventually building that sample into a full-fledged, robust, and battle-tested networking system.

  • 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)
    Ceras now has a dedicated AotMode in the config and a code-generator (quick guide for it here) for IL2CPP/Unity/AoT.

Support

  • Open an issue
  • Join my Discord (probably the best for direct one-on-one help)
  • Make sure you\’ve read FAQ and Optimization & Pitfalls

>> FAQ

>> Development Blog

下载源码

通过命令行克隆项目:

git clone https://github.com/rikimaru0345/Ceras.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 开发教程 Ceras https://www.zuozi.net/31480.html

Houdini Fun
上一篇: Houdini Fun
SelectCource
下一篇: SelectCource
常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务