mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
removed from_bytes from trait
This commit is contained in:
@@ -11,13 +11,6 @@ pub trait VecZnxApi {
|
|||||||
/// Returns the minimum size of the [u8] array required to assign a
|
/// Returns the minimum size of the [u8] array required to assign a
|
||||||
/// new backend array to a [VecZnx] through [VecZnx::from_bytes].
|
/// new backend array to a [VecZnx] through [VecZnx::from_bytes].
|
||||||
fn bytes_of(n: usize, limbs: usize) -> usize;
|
fn bytes_of(n: usize, limbs: usize) -> usize;
|
||||||
/// Returns a new struct implementing [VecZnxApi] with the provided data as backing array.
|
|
||||||
///
|
|
||||||
/// The struct will take ownership of buf[..[VecZnx::bytes_of]]
|
|
||||||
///
|
|
||||||
/// User must ensure that data is properly alligned and that
|
|
||||||
/// the size of data is at least equal to [Module::bytes_of_vec_znx].
|
|
||||||
fn from_bytes(n: usize, limbs: usize, bytes: &mut [u8]) -> impl VecZnxApi;
|
|
||||||
fn as_ptr(&self) -> *const i64;
|
fn as_ptr(&self) -> *const i64;
|
||||||
fn as_mut_ptr(&mut self) -> *mut i64;
|
fn as_mut_ptr(&mut self) -> *mut i64;
|
||||||
fn at(&self, i: usize) -> &[i64];
|
fn at(&self, i: usize) -> &[i64];
|
||||||
@@ -38,12 +31,14 @@ pub struct VecZnxBorrow {
|
|||||||
pub data: *mut i64,
|
pub data: *mut i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VecZnxApi for VecZnxBorrow {
|
impl VecZnxBorrow {
|
||||||
fn bytes_of(n: usize, limbs: usize) -> usize {
|
/// Returns a new struct implementing [VecZnxApi] with the provided data as backing array.
|
||||||
bytes_of_vec_znx(n, limbs)
|
///
|
||||||
}
|
/// The struct will take ownership of buf[..[VecZnx::bytes_of]]
|
||||||
|
///
|
||||||
fn from_bytes(n: usize, limbs: usize, bytes: &mut [u8]) -> impl VecZnxApi {
|
/// User must ensure that data is properly alligned and that
|
||||||
|
/// the size of data is at least equal to [Module::bytes_of_vec_znx].
|
||||||
|
pub fn from_bytes(n: usize, limbs: usize, bytes: &mut [u8]) -> impl VecZnxApi {
|
||||||
let size = Self::bytes_of(n, limbs);
|
let size = Self::bytes_of(n, limbs);
|
||||||
assert!(
|
assert!(
|
||||||
bytes.len() >= size,
|
bytes.len() >= size,
|
||||||
@@ -59,6 +54,12 @@ impl VecZnxApi for VecZnxBorrow {
|
|||||||
data: cast_mut(&mut bytes[..size]).as_mut_ptr(),
|
data: cast_mut(&mut bytes[..size]).as_mut_ptr(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl VecZnxApi for VecZnxBorrow {
|
||||||
|
fn bytes_of(n: usize, limbs: usize) -> usize {
|
||||||
|
bytes_of_vec_znx(n, limbs)
|
||||||
|
}
|
||||||
|
|
||||||
fn as_ptr(&self) -> *const i64 {
|
fn as_ptr(&self) -> *const i64 {
|
||||||
self.data
|
self.data
|
||||||
@@ -116,18 +117,14 @@ impl VecZnxApi for VecZnxBorrow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VecZnxApi for VecZnx {
|
impl VecZnx {
|
||||||
fn bytes_of(n: usize, limbs: usize) -> usize {
|
|
||||||
bytes_of_vec_znx(n, limbs)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns a new struct implementing [VecZnxApi] with the provided data as backing array.
|
/// Returns a new struct implementing [VecZnxApi] with the provided data as backing array.
|
||||||
///
|
///
|
||||||
/// The struct will take ownership of buf[..[VecZnx::bytes_of]]
|
/// The struct will take ownership of buf[..[VecZnx::bytes_of]]
|
||||||
///
|
///
|
||||||
/// User must ensure that data is properly alligned and that
|
/// User must ensure that data is properly alligned and that
|
||||||
/// the size of data is at least equal to [Module::bytes_of_vec_znx].
|
/// the size of data is at least equal to [Module::bytes_of_vec_znx].
|
||||||
fn from_bytes(n: usize, limbs: usize, buf: &mut [u8]) -> impl VecZnxApi {
|
pub fn from_bytes(n: usize, limbs: usize, buf: &mut [u8]) -> impl VecZnxApi {
|
||||||
let size = Self::bytes_of(n, limbs);
|
let size = Self::bytes_of(n, limbs);
|
||||||
assert!(
|
assert!(
|
||||||
buf.len() >= size,
|
buf.len() >= size,
|
||||||
@@ -143,6 +140,12 @@ impl VecZnxApi for VecZnx {
|
|||||||
data: alias_mut_slice_to_vec(cast_mut(&mut buf[..size])),
|
data: alias_mut_slice_to_vec(cast_mut(&mut buf[..size])),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl VecZnxApi for VecZnx {
|
||||||
|
fn bytes_of(n: usize, limbs: usize) -> usize {
|
||||||
|
bytes_of_vec_znx(n, limbs)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns a non-mutable pointer to the backing array of the [VecZnx].
|
/// Returns a non-mutable pointer to the backing array of the [VecZnx].
|
||||||
fn as_ptr(&self) -> *const i64 {
|
fn as_ptr(&self) -> *const i64 {
|
||||||
|
|||||||
Reference in New Issue
Block a user