Renamed AMfreeResult()
to AMresultFree()
.
Remove the `&AMchange` conversion for `AMbyteSpan`. Add a `&automerge::ActorId` conversion to for `AMbyteSpan`. Remove the `&Vec<u8>` conversion for `AMbyteSpan`. Add a `&[u8]` conversion for `AMbyteSpan`.
This commit is contained in:
parent
4bed03f008
commit
5765fea771
1 changed files with 14 additions and 13 deletions
|
@ -1,16 +1,14 @@
|
|||
use automerge as am;
|
||||
|
||||
use crate::AMchange;
|
||||
|
||||
/// \struct AMbyteSpan
|
||||
/// \brief A contiguous sequence of bytes.
|
||||
///
|
||||
#[repr(C)]
|
||||
pub struct AMbyteSpan {
|
||||
/// A pointer to an array of bytes.
|
||||
/// \warning \p src is only valid until the `AMfreeResult()` function is called
|
||||
/// on the `AMresult` struct hosting the array of bytes to which
|
||||
/// it points.
|
||||
/// \warning \p src is only valid until the `AMresultFree()` function is
|
||||
/// called on the `AMresult` struct hosting the array of bytes to
|
||||
/// which it points.
|
||||
src: *const u8,
|
||||
/// The number of bytes in the array.
|
||||
count: usize,
|
||||
|
@ -25,10 +23,13 @@ impl Default for AMbyteSpan {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<&AMchange> for AMbyteSpan {
|
||||
fn from(change: &AMchange) -> Self {
|
||||
let change_hash = &(change.as_ref()).hash;
|
||||
change_hash.into()
|
||||
impl From<&am::ActorId> for AMbyteSpan {
|
||||
fn from(actor: &am::ActorId) -> Self {
|
||||
let slice = actor.to_bytes();
|
||||
Self {
|
||||
src: slice.as_ptr(),
|
||||
count: slice.len(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,11 +52,11 @@ impl From<&am::ChangeHash> for AMbyteSpan {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<&Vec<u8>> for AMbyteSpan {
|
||||
fn from(v: &Vec<u8>) -> Self {
|
||||
impl From<&[u8]> for AMbyteSpan {
|
||||
fn from(slice: &[u8]) -> Self {
|
||||
Self {
|
||||
src: (*v).as_ptr(),
|
||||
count: (*v).len(),
|
||||
src: slice.as_ptr(),
|
||||
count: slice.len(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue