feat(napi): implement From<String> for Buffer (#2002)
This commit is contained in:
parent
50623ca26b
commit
693f0ac269
1 changed files with 6 additions and 0 deletions
|
@ -234,6 +234,12 @@ impl From<&[u8]> for Buffer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<String> for Buffer {
|
||||||
|
fn from(inner: String) -> Self {
|
||||||
|
Buffer::from(inner.into_bytes())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl AsRef<[u8]> for Buffer {
|
impl AsRef<[u8]> for Buffer {
|
||||||
fn as_ref(&self) -> &[u8] {
|
fn as_ref(&self) -> &[u8] {
|
||||||
// SAFETY: the pointer is guaranteed to be non-null, and guaranteed to be valid if `len` is not 0.
|
// SAFETY: the pointer is guaranteed to be non-null, and guaranteed to be valid if `len` is not 0.
|
||||||
|
|
Loading…
Reference in a new issue