Skip to content

Commit 8bc8b54

Browse files
committed
feat: better with_height
1 parent fe6a248 commit 8bc8b54

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Diff for: src/lib.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,19 @@ pub mod prelude {
114114
}
115115
}
116116

117-
pub trait CosmosRequest<T> {
118-
fn with_height(&mut self, height: MetadataValue<Ascii>) -> &mut Self;
119-
}
120-
121-
impl<T> CosmosRequest<T> for tonic::Request<T> {
122-
fn with_height(&mut self, height: MetadataValue<Ascii>) -> &mut Self {
123-
self.metadata_mut().insert(HEIGHT_METADATA_KEY, height);
124-
125-
self
117+
pub trait CosmosMessage {
118+
fn with_height(self, height: MetadataValue<Ascii>) -> tonic::Request<Self>
119+
where
120+
Self: Sized,
121+
{
122+
let mut req = tonic::Request::new(self);
123+
req.metadata_mut().insert(HEIGHT_METADATA_KEY, height);
124+
req
126125
}
127126
}
128127

128+
impl<T> CosmosMessage for T {}
129+
129130
pub trait CosmosResponse<T> {
130131
fn get_height(&self) -> Option<&MetadataValue<Ascii>>;
131132
}

0 commit comments

Comments
 (0)