use hedera_proto::services;
use crate::{
FileId,
FromProtobuf,
};
#[derive(Debug, Clone)]
#[cfg_attr(feature = "ffi", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "ffi", serde(rename_all = "camelCase"))]
pub struct FileContentsResponse {
pub file_id: FileId,
#[cfg_attr(feature = "ffi", serde(with = "serde_with::As::<serde_with::base64::Base64>"))]
pub contents: Vec<u8>,
}
impl FromProtobuf<services::response::Response> for FileContentsResponse {
fn from_protobuf(pb: services::response::Response) -> crate::Result<Self>
where
Self: Sized,
{
let pb = pb_getv!(pb, FileGetContents, services::response::Response);
let file_contents = pb_getf!(pb, file_contents)?;
let file_id = pb_getf!(file_contents, file_id)?;
let contents = file_contents.contents;
let file_id = FileId::from_protobuf(file_id)?;
Ok(Self { file_id, contents })
}
}