Renamed Value to JsonValue to make things a little more clear
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
debug::debug_path_mismatch,
|
||||
json_crdt::{CrdtNode, OpState, Value},
|
||||
json_crdt::{CrdtNode, JsonValue, OpState},
|
||||
keypair::AuthorId,
|
||||
op::*,
|
||||
};
|
||||
@@ -48,7 +48,7 @@ where
|
||||
}
|
||||
|
||||
/// Locally insert some content causally after the given operation
|
||||
pub fn insert<U: Into<Value>>(&mut self, after: OpId, content: U) -> Op<Value> {
|
||||
pub fn insert<U: Into<JsonValue>>(&mut self, after: OpId, content: U) -> Op<JsonValue> {
|
||||
let mut op = Op::new(
|
||||
after,
|
||||
self.our_id,
|
||||
@@ -67,7 +67,11 @@ where
|
||||
}
|
||||
|
||||
/// Shorthand function to insert at index locally. Indexing ignores deleted items
|
||||
pub fn insert_idx<U: Into<Value> + Clone>(&mut self, idx: usize, content: U) -> Op<Value> {
|
||||
pub fn insert_idx<U: Into<JsonValue> + Clone>(
|
||||
&mut self,
|
||||
idx: usize,
|
||||
content: U,
|
||||
) -> Op<JsonValue> {
|
||||
let mut i = 0;
|
||||
for op in &self.ops {
|
||||
if !op.is_deleted {
|
||||
@@ -97,7 +101,7 @@ where
|
||||
|
||||
/// Mark a node as deleted. If the node doesn't exist, it will be stuck
|
||||
/// waiting for that node to be created.
|
||||
pub fn delete(&mut self, id: OpId) -> Op<Value> {
|
||||
pub fn delete(&mut self, id: OpId) -> Op<JsonValue> {
|
||||
let op = Op::new(
|
||||
id,
|
||||
self.our_id,
|
||||
@@ -117,7 +121,7 @@ where
|
||||
|
||||
/// Apply an operation (both local and remote) to this local list CRDT.
|
||||
/// Forwards it to a nested CRDT if necessary.
|
||||
pub fn apply(&mut self, op: Op<Value>) -> OpState {
|
||||
pub fn apply(&mut self, op: Op<JsonValue>) -> OpState {
|
||||
if !op.is_valid_hash() {
|
||||
return OpState::ErrHashMismatch;
|
||||
}
|
||||
@@ -308,11 +312,11 @@ impl<T> CrdtNode for ListCrdt<T>
|
||||
where
|
||||
T: CrdtNode,
|
||||
{
|
||||
fn apply(&mut self, op: Op<Value>) -> OpState {
|
||||
fn apply(&mut self, op: Op<JsonValue>) -> OpState {
|
||||
self.apply(op.into())
|
||||
}
|
||||
|
||||
fn view(&self) -> Value {
|
||||
fn view(&self) -> JsonValue {
|
||||
self.view().into()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user