Writes a slice of `f32` to a pd named array. Reads values as much as `read_amount` from the array which is given as the `source` argument and writes them to a named array in pd which is specified with `destination_name` argument starting at `destination_write_offset`. # Example ```no_run use libpd_rs::functions::array::write_float_array_to; let mut source = [1.0_f32; 64]; write_float_array_to("
(
destination_name: T,
destination_write_offset: i32,
source: &[f32],
source_read_amount: i32,
)
| 167 | /// - [`FailedToFindArray`](crate::error::ArrayError::FailedToFindArray) |
| 168 | /// - [`StringConversion`](crate::error::ArrayError::StringConversion) |
| 169 | pub fn write_float_array_to<T: AsRef<str>>( |
| 170 | destination_name: T, |
| 171 | destination_write_offset: i32, |
| 172 | source: &[f32], |
| 173 | source_read_amount: i32, |
| 174 | ) -> Result<(), ArrayError> { |
| 175 | unsafe { |
| 176 | let name = CString::new(destination_name.as_ref()).map_err(StringConversionError::from)?; |
| 177 | // Returns 0 on success or a negative error code if the array is non-existent |
| 178 | // or offset + n exceeds range of array |
| 179 | |
| 180 | #[expect( |
| 181 | clippy::cast_sign_loss, |
| 182 | reason = "We check this manually in the predicate." |
| 183 | )] |
| 184 | if destination_write_offset + source_read_amount |
| 185 | > array_size(destination_name.as_ref()).map_err(|_| ArrayError::FailedToFindArray)? |
| 186 | || source_read_amount < 0 |
| 187 | || source_read_amount as usize > source.len() |
| 188 | { |
| 189 | return Err(ArrayError::OutOfBounds); |
| 190 | } |
| 191 | |
| 192 | match libpd_sys::libpd_write_array( |
| 193 | name.as_ptr(), |
| 194 | destination_write_offset, |
| 195 | source.as_ptr(), |
| 196 | source_read_amount, |
| 197 | ) { |
| 198 | 0 => Ok(()), |
| 199 | _ => Err(ArrayError::FailedToFindArray), |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | /// Reads a named array from pd to a mutable slice of `f64`. |
| 205 | /// |