use crate::Result;
use crate::model::{Object, ReadObjectRequest};
use crate::model_ext::WriteObjectRequest;
use crate::read_object::ReadObjectResponse;
use crate::storage::request_options::RequestOptions;
use crate::streaming_source::{Seek, StreamingSource};
use crate::{
http::HeaderMap,
model_ext::{OpenObjectRequest, ReadRange},
object_descriptor::ObjectDescriptor as Descriptor,
};
#[cfg(google_cloud_unstable_storage_bidi)]
use bytes::Bytes;
use gaxi::unimplemented::UNIMPLEMENTED;
pub trait Storage: std::fmt::Debug + Send + Sync {
fn read_object(
&self,
_req: ReadObjectRequest,
_options: RequestOptions,
) -> impl std::future::Future<Output = Result<ReadObjectResponse>> + Send {
unimplemented_stub::<ReadObjectResponse>()
}
fn write_object_buffered<P>(
&self,
_payload: P,
_req: WriteObjectRequest,
_options: RequestOptions,
) -> impl std::future::Future<Output = Result<Object>> + Send
where
P: StreamingSource + Send + Sync + 'static,
{
unimplemented_stub::<Object>()
}
fn write_object_unbuffered<P>(
&self,
_payload: P,
_req: WriteObjectRequest,
_options: RequestOptions,
) -> impl std::future::Future<Output = Result<Object>> + Send
where
P: StreamingSource + Seek + Send + Sync + 'static,
{
unimplemented_stub::<Object>()
}
fn open_object(
&self,
_request: OpenObjectRequest,
_options: RequestOptions,
) -> impl std::future::Future<Output = Result<(Descriptor, Vec<ReadObjectResponse>)>> + Send
{
unimplemented_stub::<(Descriptor, Vec<ReadObjectResponse>)>()
}
}
pub trait ObjectDescriptor: std::fmt::Debug + Send + Sync {
fn object(&self) -> Object;
fn read_range(&self, range: ReadRange) -> impl Future<Output = ReadObjectResponse> + Send;
fn headers(&self) -> HeaderMap;
}
#[cfg(google_cloud_unstable_storage_bidi)]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-stream")))]
pub trait AppendableObjectWriter: std::fmt::Debug + Send + Sync {
fn append(
&mut self,
chunk: Bytes,
) -> impl std::future::Future<Output = crate::Result<()>> + Send;
fn flush(&mut self) -> impl std::future::Future<Output = crate::Result<i64>> + Send;
fn finalize(
self,
) -> impl std::future::Future<Output = crate::Result<crate::model::Object>> + Send;
fn close(self) -> impl std::future::Future<Output = crate::Result<i64>> + Send;
fn generation(&self) -> i64;
fn persisted_size(&self) -> i64;
}
async fn unimplemented_stub<T>() -> google_cloud_gax::Result<T> {
unimplemented!("{UNIMPLEMENTED}");
}