MCPcopy Create free account
hub / github.com/awslabs/llrt / endian_bytes

Function endian_bytes

modules/llrt_buffer/src/buffer.rs:794–810  ·  view source on GitHub ↗

Pure mathematical byte generation

(mut val: u64, endian: Endian)

Source from the content-addressed store, hash-verified

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 {

Callers 1

write_bufFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected