/* ddtu - digital data transferring utility Copyright (C) 2022 Kasyanov Nikolay Alexeyevich (Unbewohnte) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. */ pub fn read_u128(buf: Vec) -> u128 { let mut arr: [u8; 16] = [0; 16]; for i in 0..16 { arr[i] = buf[i]; } return u128::from_be_bytes(arr); } pub fn read_u128_slice(buf_16: &[u8]) -> u128 { let mut arr: [u8; 16] = [0; 16]; for i in 0..16 { arr[i] = buf_16[i]; } return u128::from_be_bytes(arr); } pub fn read_utf8_string(buf: Vec) -> String { return String::from_utf8_lossy(&buf).into_owned(); } pub fn read_utf8_string_slice(buf: &[u8]) -> String { return String::from_utf8_lossy(&buf).into_owned(); }