Pure mathematical byte generation
(mut val: u64, endian: Endian)
| 792 | let value = match endian { |
| 793 | Endian::Big => u8::from_be_bytes(bytes.try_into().unwrap()), |
| 794 | Endian::Little => u8::from_le_bytes(bytes.try_into().unwrap()), |
| 795 | }; |
| 796 | Value::new_int(ctx.clone(), value as i32) |
| 797 | }, |
| 798 | NumberKind::Int16 => { |
| 799 | let value = match endian { |
| 800 | Endian::Big => i16::from_be_bytes(bytes.try_into().unwrap()), |
| 801 | Endian::Little => i16::from_le_bytes(bytes.try_into().unwrap()), |
| 802 | }; |
| 803 | Value::new_int(ctx.clone(), value as i32) |
| 804 | }, |
| 805 | NumberKind::UInt16 => { |
| 806 | let value = match endian { |
| 807 | Endian::Big => u16::from_be_bytes(bytes.try_into().unwrap()), |
| 808 | Endian::Little => u16::from_le_bytes(bytes.try_into().unwrap()), |
| 809 | }; |
| 810 | Value::new_int(ctx.clone(), value as i32) |
| 811 | }, |
| 812 | NumberKind::Int32 => { |
| 813 | let value = match endian { |