switchboard-protos 0.1.60

Generated protocol buffers to support Switchboard on Solana
Documentation
// Automatically generated rust module for 'vrf.proto' file

#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![cfg_attr(rustfmt, rustfmt_skip)]


use quick_protobuf::{MessageRead, MessageWrite, BytesReader, Writer, WriterBackend, Result};
use quick_protobuf::sizeofs::*;
use super::*;

#[derive(Debug, Default, PartialEq, Clone)]
pub struct VrfAccountData {
    pub self_pubkey: Option<Vec<u8>>,
    pub randomness_producer_pubkey: Option<Vec<u8>>,
    pub fulfillment_manager_pubkey: Option<Vec<u8>>,
    pub min_proof_confirmations: Option<i32>,
    pub lock_configs: Option<bool>,
    pub counter: Option<u64>,
    pub msg: Option<Vec<u8>>,
    pub value: Option<Vec<u8>>,
    pub proof: Option<Vec<u8>>,
    pub num_proof_confirmations: Option<i32>,
    pub last_request_timestamp: Option<i64>,
    pub verifier_pubkeys: Vec<Vec<u8>>,
}

impl<'a> MessageRead<'a> for VrfAccountData {
    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
        let mut msg = Self::default();
        while !r.is_eof() {
            match r.next_tag(bytes) {
                Ok(10) => msg.self_pubkey = Some(r.read_bytes(bytes)?.to_owned()),
                Ok(18) => msg.randomness_producer_pubkey = Some(r.read_bytes(bytes)?.to_owned()),
                Ok(26) => msg.fulfillment_manager_pubkey = Some(r.read_bytes(bytes)?.to_owned()),
                Ok(32) => msg.min_proof_confirmations = Some(r.read_int32(bytes)?),
                Ok(40) => msg.lock_configs = Some(r.read_bool(bytes)?),
                Ok(48) => msg.counter = Some(r.read_uint64(bytes)?),
                Ok(58) => msg.msg = Some(r.read_bytes(bytes)?.to_owned()),
                Ok(66) => msg.value = Some(r.read_bytes(bytes)?.to_owned()),
                Ok(74) => msg.proof = Some(r.read_bytes(bytes)?.to_owned()),
                Ok(80) => msg.num_proof_confirmations = Some(r.read_int32(bytes)?),
                Ok(88) => msg.last_request_timestamp = Some(r.read_int64(bytes)?),
                Ok(98) => msg.verifier_pubkeys.push(r.read_bytes(bytes)?.to_owned()),
                Ok(t) => { r.read_unknown(bytes, t)?; }
                Err(e) => return Err(e),
            }
        }
        Ok(msg)
    }
}

impl MessageWrite for VrfAccountData {
    fn get_size(&self) -> usize {
        0
        + self.self_pubkey.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
        + self.randomness_producer_pubkey.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
        + self.fulfillment_manager_pubkey.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
        + self.min_proof_confirmations.as_ref().map_or(0, |m| 1 + sizeof_varint(*(m) as u64))
        + self.lock_configs.as_ref().map_or(0, |m| 1 + sizeof_varint(*(m) as u64))
        + self.counter.as_ref().map_or(0, |m| 1 + sizeof_varint(*(m) as u64))
        + self.msg.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
        + self.value.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
        + self.proof.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
        + self.num_proof_confirmations.as_ref().map_or(0, |m| 1 + sizeof_varint(*(m) as u64))
        + self.last_request_timestamp.as_ref().map_or(0, |m| 1 + sizeof_varint(*(m) as u64))
        + self.verifier_pubkeys.iter().map(|s| 1 + sizeof_len((s).len())).sum::<usize>()
    }

    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
        if let Some(ref s) = self.self_pubkey { w.write_with_tag(10, |w| w.write_bytes(&**s))?; }
        if let Some(ref s) = self.randomness_producer_pubkey { w.write_with_tag(18, |w| w.write_bytes(&**s))?; }
        if let Some(ref s) = self.fulfillment_manager_pubkey { w.write_with_tag(26, |w| w.write_bytes(&**s))?; }
        if let Some(ref s) = self.min_proof_confirmations { w.write_with_tag(32, |w| w.write_int32(*s))?; }
        if let Some(ref s) = self.lock_configs { w.write_with_tag(40, |w| w.write_bool(*s))?; }
        if let Some(ref s) = self.counter { w.write_with_tag(48, |w| w.write_uint64(*s))?; }
        if let Some(ref s) = self.msg { w.write_with_tag(58, |w| w.write_bytes(&**s))?; }
        if let Some(ref s) = self.value { w.write_with_tag(66, |w| w.write_bytes(&**s))?; }
        if let Some(ref s) = self.proof { w.write_with_tag(74, |w| w.write_bytes(&**s))?; }
        if let Some(ref s) = self.num_proof_confirmations { w.write_with_tag(80, |w| w.write_int32(*s))?; }
        if let Some(ref s) = self.last_request_timestamp { w.write_with_tag(88, |w| w.write_int64(*s))?; }
        for s in &self.verifier_pubkeys { w.write_with_tag(98, |w| w.write_bytes(&**s))?; }
        Ok(())
    }
}

#[derive(Debug, Default, PartialEq, Clone)]
pub struct VrfPermitAccountData {
    pub granter: Option<Vec<u8>>,
    pub grantee: Option<Vec<u8>>,
    pub enabled: Option<bool>,
}

impl<'a> MessageRead<'a> for VrfPermitAccountData {
    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
        let mut msg = Self::default();
        while !r.is_eof() {
            match r.next_tag(bytes) {
                Ok(10) => msg.granter = Some(r.read_bytes(bytes)?.to_owned()),
                Ok(18) => msg.grantee = Some(r.read_bytes(bytes)?.to_owned()),
                Ok(24) => msg.enabled = Some(r.read_bool(bytes)?),
                Ok(t) => { r.read_unknown(bytes, t)?; }
                Err(e) => return Err(e),
            }
        }
        Ok(msg)
    }
}

impl MessageWrite for VrfPermitAccountData {
    fn get_size(&self) -> usize {
        0
        + self.granter.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
        + self.grantee.as_ref().map_or(0, |m| 1 + sizeof_len((m).len()))
        + self.enabled.as_ref().map_or(0, |m| 1 + sizeof_varint(*(m) as u64))
    }

    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
        if let Some(ref s) = self.granter { w.write_with_tag(10, |w| w.write_bytes(&**s))?; }
        if let Some(ref s) = self.grantee { w.write_with_tag(18, |w| w.write_bytes(&**s))?; }
        if let Some(ref s) = self.enabled { w.write_with_tag(24, |w| w.write_bool(*s))?; }
        Ok(())
    }
}