Skip to content

Commit fda9fd2

Browse files
authored
docs(storage): documentation for write_object() (#3174)
1 parent f380591 commit fda9fd2

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

src/storage/src/storage/client.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,7 @@ where
135135
}
136136
}
137137

138-
/// Write an object using a local buffer.
139-
///
140-
/// If the data source does **not** implement [Seek] the client library must
141-
/// buffer data sent to the service until the service confirms it has
142-
/// persisted the data. This requires more memory in the client, and when
143-
/// the buffer grows too large, may require stalling the writer until the
144-
/// service can persist the data.
145-
///
146-
/// Use this function for data sources representing computations where
147-
/// it is expensive or impossible to restart said computation. This function
148-
/// is also useful when it is hard or impossible to predict the number of
149-
/// bytes emitted by a stream, even if restarting the stream is not too
150-
/// expensive.
138+
/// Write an object with data from any data source.
151139
///
152140
/// # Example
153141
/// ```
@@ -173,13 +161,23 @@ where
173161
/// # Ok(()) }
174162
/// ```
175163
///
164+
/// You can use many different types as the payload. For example, a string,
165+
/// a [bytes::Bytes], a [tokio::fs::File], or a custom type that implements
166+
/// the [StreamingSource] trait.
167+
///
168+
/// If your data source also implements [Seek], prefer [send_unbuffered()]
169+
/// to start the write. Otherwise use [send_buffered()].
170+
///
176171
/// # Parameters
177172
/// * `bucket` - the bucket name containing the object. In
178173
/// `projects/_/buckets/{bucket_id}` format.
179174
/// * `object` - the object name.
180175
/// * `payload` - the object data.
181176
///
182177
/// [Seek]: crate::streaming_source::Seek
178+
/// [StreamingSource]: crate::streaming_source::StreamingSource
179+
/// [send_buffered()]: crate::builder::storage::WriteObject::send_buffered
180+
/// [send_unbuffered()]: crate::builder::storage::WriteObject::send_unbuffered
183181
pub fn write_object<B, O, T, P>(&self, bucket: B, object: O, payload: T) -> WriteObject<P, S>
184182
where
185183
B: Into<String>,

src/storage/src/storage/write_object.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,17 @@ where
10091009
{
10101010
/// Upload an object from a streaming source without rewinds.
10111011
///
1012+
/// If the data source does **not** implement [Seek] the client library must
1013+
/// buffer data sent to the service until the service confirms it has
1014+
/// persisted the data. This requires more memory in the client, and when
1015+
/// the buffer grows too large, may require stalling the writer until the
1016+
/// service can persist the data.
1017+
///
1018+
/// Use this function for data sources where it is expensive or impossible
1019+
/// to restart the data source. This function is also useful when it is hard
1020+
/// or impossible to predict the number of bytes emitted by a stream, even
1021+
/// if restarting the stream is not too expensive.
1022+
///
10121023
/// # Example
10131024
/// ```
10141025
/// # use google_cloud_storage::client::Storage;

0 commit comments

Comments
 (0)