kauma/src/tasks/tasks01/poly2block.rs

18 lines
494 B
Rust

use crate::utils::poly::{polynomial_2_block};
use anyhow::{Ok, Result};
use serde_json::Value;
pub fn poly2block(args: &Value) -> Result<Vec<u8>> {
let coefficients: Vec<u8> = args["coefficients"]
.as_array()
.unwrap()
.into_iter()
.map(|x| x.as_u64().unwrap() as u8)
.collect();
let semantic: String = serde_json::from_value(args["semantic"].clone())?;
let result = polynomial_2_block(coefficients, &semantic).unwrap();
Ok(result)
}