parsec-service 1.5.0

A language-agnostic API to secure services in a platform-agnostic way
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Copyright 2021 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0
use super::Context;
use super::error::Error;
use super::ts_protobuf::{GenerateRandomIn, GenerateRandomOut};
use log::info;
use std::convert::TryInto;

impl Context {
    pub fn generate_random(&self, size: usize) -> Result<Vec<u8>, Error> {
        info!("Handling GenerateRandom request");
        let open_req: GenerateRandomIn = GenerateRandomIn {
            size: size.try_into()?,
        };
        let result: GenerateRandomOut = self.send_request(&open_req)?;
        Ok(result.random_bytes)
    }
}