8 Commits

Author SHA1 Message Date
ff3558ea37 The conversion of an Array of bytes to a value can now fail gracefully.
This was added so that parsers can detect problems converting
a value and fail in an expected way.
2018-01-05 19:20:02 -05:00
03e9484e52 Fixed the conversion code to use macros I wrote.
The previous code was relying on the to_be and to_le functions from the
standard library. These now rely on macros that I wrote to handle the
bit packing and unpacking. These were macros and not functions because
it is really hard to define the types and capabilities needed to
turn them into general functions. As such, the macros should never be
published publically and the Converters should be used for conversions.

The Transmutable property should be used for serialization and internally
the primitive types, Elements, all use the Converter functions and any
other objects should use the Transmutable primitives to build their
binary forms.
2017-02-15 17:51:13 -05:00
3b01eed3e0 Added platform endianess detection and fixed String byte conversion. 2016-12-18 03:20:31 -05:00
Jason Travis Smith
4291a1ef5d Any conversion to bytes now uses a Vec<u8>.
This was changed to make everything easier to use. The mutable buffers
were not working well for combined types. It was move to a growable array
to make these more advanced combined types, other structures, easier to
implement.
2016-04-14 13:33:07 -04:00
Jason Travis Smith
aa4bb78f66 Vector types are now Transmutable.
A Vector can now be converted to and from bytes of data.
I'm not entirely sure that the structure bytes do not have to
be handled for endianess, but the underlying basic types are
correctly handled.

Tests and and example have also be created. The tests lib file was split
into a converter test file and a transmutable test file.
2016-01-07 05:10:50 -05:00
Jason Travis Smith
ed44f4f861 Created a trait for specifying byte size for a type.
There is now a ByteSized trait that can be used to specify how many
bytes it takes to represent a piece of data. This has been implemented
for all of the primitive number types. With this information Transmutable
was able to create a Vector2 wrapper that will need to be tested. If it
works then soon after Vectors and other Sigils types can be turned into
Transmutable types.

This also has the changes for the original tests and example
to use the new ByteSized information.
2016-01-06 23:37:18 -05:00
Jason Travis Smith
d9a3e21aec Fixed the example and tests to use the new Converter trait.
Transmutable was changed to Converter. This needed to be reflected in
the example and tests.

Also, fixed some comments in the new transmutable module.
2016-01-05 23:42:08 -05:00
Jason Travis Smith
8ae59008fe This is an example of how to use the library.
This example converts a 32-bit floating point value
to and from a byte array.
2015-12-30 17:54:23 -05:00