Skip to content

Commit baf8621

Browse files
authored
minor doc and arg improvements (#61)
* Take JSON value by reference in InitialData::from_json * Fix backticks around some types in docs
1 parent 1a31d11 commit baf8621

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
- prost 0.9.0 -> 0.10.0
2626
- tonic 0.6.0 -> 0.7.0
2727
- tonic-health 0.5.0 -> 0.6.0
28+
- `InitialData::from_json` now only takes the desired JSON `Value` by reference rather than by
29+
value.
2830

2931
## [0.2.0] - 2022-03-15
3032

src/backend/stream.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ impl InitialData {
9090
}
9191

9292
/// Create some initial data representing some JSON.
93-
pub fn from_json(json: serde_json::Value) -> Result<Self, ConvertToError> {
93+
pub fn from_json(json: &serde_json::Value) -> Result<Self, ConvertToError> {
9494
Ok(Self {
95-
data: serde_json::to_vec(&json).map_err(|err| ConvertToError::InvalidJson { err })?,
95+
data: serde_json::to_vec(json).map_err(|err| ConvertToError::InvalidJson { err })?,
9696
})
9797
}
9898
}
@@ -215,7 +215,7 @@ pub struct StreamPacket<J = ()> {
215215
}
216216

217217
impl<J> StreamPacket<J> {
218-
/// Create a StreamPacket representing a `Frame`.
218+
/// Create a `StreamPacket` representing a `Frame`.
219219
pub fn from_frame(frame: data::CheckedFrame<'_>) -> Result<Self, ConvertToError> {
220220
Ok(Self {
221221
data: frame
@@ -225,7 +225,7 @@ impl<J> StreamPacket<J> {
225225
})
226226
}
227227

228-
/// Create a StreamPacket representing some JSON.
228+
/// Create a `StreamPacket` representing some JSON.
229229
pub fn from_json(json: &J) -> Result<Self, ConvertToError>
230230
where
231231
J: Serialize,
@@ -236,7 +236,7 @@ impl<J> StreamPacket<J> {
236236
})
237237
}
238238

239-
/// Create a StreamPacket from arbitrary bytes.
239+
/// Create a `StreamPacket` from arbitrary bytes.
240240
pub fn from_bytes(data: Vec<u8>) -> Self {
241241
Self {
242242
data,

0 commit comments

Comments
 (0)