51 Commits

Author SHA1 Message Date
f1f16c0b9d Updated to use the new dyn syntax. 2020-07-02 23:37:57 -04:00
114d76a0db Fixed a scribe use mistake. 2019-01-21 23:27:41 -05:00
c6412f98a0 Fixed a warning of attempt never being used.
This is due to attempt only being needed when converting sigil members.
2019-01-21 21:10:33 -05:00
eec868b406 Rust no longer requires extern crate calls as of the 2018 update.
Update all the examples to work with the spellbook Array class as well.
2019-01-20 20:38:42 -05:00
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
16d073b1f9 Fixing some comments and format problems. 2018-01-19 14:58:43 -05:00
27a3195bea Added a couple new Errors that can be supplied during transmutation.
Added an error for a corruption detection of the given bytes. This was
added so that an inproper CRC code when reading a PNG file could
throw an Error.

Added an error for an invalid value being transmuted from the given bytes.
This was added so that an Error can be thrown when a value outside of
a given range is parsed.
2018-01-08 23:36:15 -05:00
12096a5136 Removed the library pathing for ConversionError from check_length!(). 2018-01-05 23:37:09 -05:00
4295886f25 The check length macro was exported for use by other libraries.
This was done to make buffer length checks common through out.
2018-01-05 23:32:16 -05: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
3a1b847c51 Fixed this to return the correct conversion. I hope... 2017-07-01 20:18:00 -04:00
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
8988f9f9ae This library has reach version 1.0.0!
This library is relatively stable and has been gone over pretty well.
As such, it is now at version 1.0.0 and is considered ready for
public release (Use in the public space, not giving the code away).
2016-12-22 19:13:50 -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
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
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
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
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
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
8075e68607 Forgot to check in the ByteSized file in the last commit. 2016-01-06 23:37:42 -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
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
a3cc3a3515 Merge branch 'examples' 2015-12-30 22:25:09 -05:00
Jason Travis Smith
9b280f8c43 Added a README file to the project. 2015-12-30 22:24:41 -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
Jason Travis Smith
f48b8ba98b Creating the tests for the Alchemy library. 2015-12-30 17:14:48 -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