ziglibs / s2s Goto Github PK
View Code? Open in Web Editor NEWA zig binary serialization format.
License: MIT License
A zig binary serialization format.
License: MIT License
Similarly to how std.fmt
supports adding a format()
function to a struct or union, s2s should support it for custom serialization/deserialization or for when a type isn't fully supported. This would help with unsupported types that can't easily be serialized due to recursiveness.
when i run test give me this error
s2s.zig:474:49: error: no field named 'little' in enum 'builtin.Endian' std.mem.writeInt(AlignedInt(T), &res, val, .little); ~^~~~~~ C:\zig\lib\std\builtin.zig:452:20: note: enum declared here pub const Endian = enum { ^~~~ s2s.zig:486:34: note: called from here return intToLittleEndianBytes(hasher.final()); ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ s2s.zig:189:47: note: called from here const type_hash = comptime computeTypeHash(T); ~~~~~~~~~~~~~~~^~~
var known_at_runtime_zero: usize = 0;
const hello = [_][]const u8{"hello"};
//@compileLog(hello);
// Compile Log Output:
//@as([1][]const u8, .{ .{ 104, 101, 108, 108, 111 } })
try testSerDesAlloc([1][]const u8, hello);
gives error trace
Test [3/3] test.ser/des... index 0 incorrect. expected { 104, 101, 108, 108, 111 }, found { 104, 101, 108, 108, 111 }
Test [3/3] test.ser/des... FAIL (TestExpectedEqual)
/firefox/home/.local/zig/zig-linux-x86_64-0.10.0-dev.4060+61aaef0b0/lib/std/testing.zig:301:13: 0x232c93 in expectEqualSlices__anon_2505 (test)
return error.TestExpectedEqual;
^
/firefox/home/.local/zig/zig-linux-x86_64-0.10.0-dev.4060+61aaef0b0/lib/std/testing.zig:108:27: 0x232ed5 in expectEqual__anon_2504 (test)
.Array => |array| try expectEqualSlices(array.child, &expected, &actual),
^
./s2s.zig:804:5: 0x233085 in testSerDesAlloc__anon_2499 (test)
try std.testing.expectEqual(value, deserialized);
^
./s2s.zig:859:5: 0x239bac in test.ser/des (test)
try testSerDesAlloc([1][]const u8, hello);
^
2 passed; 0 skipped; 1 failed.
error: the following test command failed with exit code 1:
zig-cache/o/9169a8a11ae643506497cd13316a9a5d/test /firefox/home/.local/zig/zig-linux-x86_64-0.10.0-dev.4060+61aaef0b0/zig
But it can clearly be seen that the expected and found bytes are the same
And on a related issue these test cases also fails
try testSerDesPtrContentEquality(*const [1][]const u8, hello[0..]);
try testSerDesSliceContentEquality([]const []const u8, hello[known_at_runtime_zero..]);
A futher example
const K = struct { value: u8 };
const works = [_]K{.{ .value = 7 }};
try testSerDesAlloc([1]K, works); //passes test which as expected
//doesn't pass test ,I think the errors are related to the above
var doesnt_works = works;
try testSerDesAlloc(*[1]K, doesnt_works[0..]);
try testSerDesAlloc([]K, doesnt_works[known_at_runtime_zero..]);
This is a reproducer of an error I am getting while using s2s in my project. I'm I misunderstanding how to use s2s or this is a genuine bug with slice ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.