Skip to content

Commit

Permalink
feat(transport): Add AsRef impl for Certificate (#326)
Browse files Browse the repository at this point in the history
Co-authored-by: IvanV <[email protected]>
  • Loading branch information
IvanVTBTL and IvanV authored Apr 9, 2020
1 parent 5d56daa commit d2ad8df
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tonic/src/transport/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@ impl Certificate {
let pem = pem.as_ref().into();
Self { pem }
}

/// Get a immutable reference to underlying certificate
pub fn get_ref(&self) -> &[u8] {
&self.pem.as_slice()
}

/// Get a mutable reference to underlying certificate
pub fn get_mut(&mut self) -> &mut [u8] {
self.pem.as_mut()
}

/// Consumes `self`, returning the underlying certificate
pub fn into_inner(self) -> Vec<u8> {
self.pem
}
}

impl AsRef<[u8]> for Certificate {
fn as_ref(&self) -> &[u8] {
self.pem.as_ref()
}
}

impl Identity {
Expand Down

0 comments on commit d2ad8df

Please sign in to comment.