23 Commits

Author SHA1 Message Date
44f23e40fd Adjusting repository locations. 2017-04-06 18:37:23 -04: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
143a6d60bc Changed the name of to_bytes to as_bytes to conform to other code.
An into_bytes function, which just called as_bytes, was decided as not
being needed because it would require that the Transmutable trait have
the requirement of being Sized. This may not be desirable in the future,
so for now there is no into_bytes. It can easily be added later with
a change to 9 lines of code.
2016-12-22 13:47:56 -05:00
04c94db9f5 Added the ability to convert the number directly to an array.
Sometimes it is better to not deal with endianess.
2016-12-21 04:22:31 -05:00
47e1c707eb Nothing was off by one. 2016-12-18 03:30:25 -05:00
d6ecace6bc Changes the LittleEndian string conversion as well. 2016-12-18 03:28:39 -05:00
ef0733b3cf The last change was off by one. 2016-12-18 03:22:42 -05:00
3b01eed3e0 Added platform endianess detection and fixed String byte conversion. 2016-12-18 03:20:31 -05:00
022f6ae87a Adds the ability to convert a value to the platform or network order.
This handles doing the configure check to see what the platform
endianess is for converting byte orders.
2016-11-03 15:04:29 -04:00
Jason Travis Smith
1ac74b27d4 Commiting any files in the project prior to reformatting. 2016-06-27 18:12:43 -04:00
Jason Travis Smith
e4d821333c Adding the concept of NetworkEndian.
NetworkEndian describes the byte order to use for network communication.
Generally, this is always BigEndian.
2016-06-17 04:34:36 -04:00
Jason Travis Smith
6ff27de3c7 Making the Endian enumeration follow the standard of CamelCase names. 2016-04-14 15:08:31 -04: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
e9ab0bdece Strings can now be transmuted or converted into binary data.
This also added the scribe library so that this library can use
the logging system.
2016-04-13 23:57:40 -04:00
Jason Travis Smith
d1c4b3e053 Converted the endian structures to enumerations.
The BigEndian and LittleEndian structures were turned into enumerations
so that they could not be instantiated.
2016-01-19 12:02:53 -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
e7f2f252fa Now supporting primitive type conversion with a trait!
This changes the old Transmutable trait to Converter and adds a new
Transmutable trait to all the primitive number types.
2016-01-05 17:46:31 -05:00
Jason Travis Smith
010abeff7c Fixed the tests to be correct.
There is now a random test for all the primitive number types.

Also, I fixed my errors with the tests that should panic. I kept thinking
that they should run fine and it was throwing off how I was writing
the code.
2016-01-03 03:22:21 -05:00
Jason Travis Smith
e6f1fbb229 Fixed the uint and int system types to not require num_bytes.
This also fixes the tests for buffer overflow to now work for all
primitive types.
2016-01-02 23:16:39 -05:00
Jason Travis Smith
7617ddb16a Merge branch 'tests'
Used the tests endian asserts.

Conflicts:
	src/endian.rs
2016-01-02 18:29:22 -05:00
Jason Travis Smith
cdd72603e5 Create a buffer overflow test.
This tests buffer overflow for the basic types. It does not currently
test the platform int and uint until the final function definitions
are determined.
2016-01-02 18:27:06 -05:00
Jason Travis Smith
6a623932ed This is trying to remove the num_bytes argument from usize/isize methods.
If num_bytes can be removed then a generic to_bytes and from_bytes
trait can be created that will help with serializing structures
and generic data.
2016-01-02 14:54:03 -05:00
Jason Travis Smith
039c093b92 The library can now convert numbers to and from bytes.
Numbers can be converted to and from bytes in both
BigEndian and LittleEndian styles. This does not yet take care of
the other mathematical structures provided by Sigil.

Also, no tests of these capabilities have been written yet.
2015-12-30 17:06:48 -05:00