24 Commits

Author SHA1 Message Date
3e4094a50c Fixed the library to use the new Rust 2018 module system. 2019-01-20 01:08:14 -05:00
0f9b3b56c5 Updated the library to use the new Array interface. 2018-04-29 04:22:42 -04:00
8f006edf09 Merge branch 'master' of gitlab.com:CyberMages/Core/alchemy
Conflicts:
	Cargo.toml
	src/converter.rs
	src/transmutable.rs

Merged the code duplication removal from transmutable into the changes
made to handle the conversion in a safer fashion.
2018-01-05 19:35:40 -05:00
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
5aa603e246 Changing to match the Spellbook DynamicArray to Array naming switch. 2017-11-28 18:47:35 -05:00
6a9e75a05c Added Sized to aid in less typing so the trait can define common funcs.
Changed the use of Vectors to the Spellbook DynamicArray class.
2017-11-23 00:02:24 -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
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
4f62caf654 Removed the Cargo.lock file from the repo and made Sigils a feature.
The Sigils library will now only be compiled in and able to convert
math structures if the convert_sigils feature is selected.

use_std would have also been set as a feature, but the library heavily
uses std::collections::vec::Vec. Until a non-std version of a collection
has been written, then this needs to be used.
2016-08-24 13:23:56 -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
26080427c0 Added a function to determine a Transmutables current byte size.
This was added so that when parsing groups of Transmutables it is easy
to determine your position in the byte array.
2016-04-14 18:08:50 -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
307118412b Upgraded to latest sigils release.
This added the ability to more easily print Vectors and Quaternions.

This also fixes some style issues.

Missing documents will now cause warnings when building.
2016-01-07 17:49:21 -05:00
Jason Travis Smith
1374ff5e4a Quaternions are now Transmutable.
This implements Transmutable for Quaternions and creates a
test and example for this conversion.
2016-01-07 05:51:53 -05: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
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
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
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