mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 07:14:50 +01:00
fix: doctests
This commit is contained in:
parent
ce8dcc8b8c
commit
721d71dd18
3 changed files with 12 additions and 11 deletions
|
@ -29,20 +29,21 @@ pub struct BufferUpdate {
|
||||||
/// new buffer, but smaller changes are efficient and easy to create or apply.
|
/// new buffer, but smaller changes are efficient and easy to create or apply.
|
||||||
///
|
///
|
||||||
/// ### Examples
|
/// ### Examples
|
||||||
/// To insert 'a' after 4th character we should send a.
|
/// To insert 'a' after 4th character we should send:
|
||||||
/// ```
|
/// ```
|
||||||
/// TextChange { start: 4, end: 4, content: "a".into(), hash: None }
|
/// codemp::api::TextChange { start: 4, end: 4, content: "a".into() };
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// To delete a the fourth character we should send a.
|
/// To delete the fourth character we should send:
|
||||||
/// ```
|
/// ```
|
||||||
/// TextChange { start: 3, end: 4, content: "".into(), hash: None }
|
/// codemp::api::TextChange { start: 3, end: 4, content: "".into() };
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// let change = codemp::api::TextChange {
|
/// let change = codemp::api::TextChange {
|
||||||
/// start: 6, end: 11,
|
/// start: 6,
|
||||||
/// content: "mom".to_string(), hash: None
|
/// end: 11,
|
||||||
|
/// content: "mom".to_string()
|
||||||
/// };
|
/// };
|
||||||
/// let before = "hello world!";
|
/// let before = "hello world!";
|
||||||
/// let after = change.apply(before);
|
/// let after = change.apply(before);
|
||||||
|
|
|
@ -36,7 +36,7 @@ impl BufferController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Notify CRDT that changes up to the given version have been merged succesfully.
|
/// Notify CRDT that changes up to the given version have been merged succesfully.
|
||||||
pub fn ack(&mut self, version: Vec<i64>) {
|
pub fn ack(&self, version: Vec<i64>) {
|
||||||
let version = version.into_iter().map(|x| usize::from_ne_bytes(x.to_ne_bytes())).collect();
|
let version = version.into_iter().map(|x| usize::from_ne_bytes(x.to_ne_bytes())).collect();
|
||||||
self.0.ack_tx
|
self.0.ack_tx
|
||||||
.send(version)
|
.send(version)
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
//! use codemp::api::controller::{AsyncSender, AsyncReceiver}; // needed to access trait methods
|
//! use codemp::api::controller::{AsyncSender, AsyncReceiver}; // needed to access trait methods
|
||||||
//! let cursor = workspace.cursor();
|
//! let cursor = workspace.cursor();
|
||||||
//! let event = cursor.recv().await.expect("disconnected while waiting for event!");
|
//! let event = cursor.recv().await.expect("disconnected while waiting for event!");
|
||||||
//! println!("user {} moved on buffer {}", event.user.unwrap_or_default(), event.buffer);
|
//! println!("user {} moved on buffer {}", event.user, event.sel.buffer);
|
||||||
//! # };
|
//! # };
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
@ -69,12 +69,12 @@
|
||||||
//! # use codemp::api::controller::{AsyncSender, AsyncReceiver};
|
//! # use codemp::api::controller::{AsyncSender, AsyncReceiver};
|
||||||
//! let buffer = workspace.attach("/some/file.txt").await.expect("failed to attach");
|
//! let buffer = workspace.attach("/some/file.txt").await.expect("failed to attach");
|
||||||
//! buffer.content(); // force-sync
|
//! buffer.content(); // force-sync
|
||||||
//! if let Some(mut delta) = buffer.try_recv().await.unwrap() {
|
//! if let Some(mut update) = buffer.try_recv().await.unwrap() {
|
||||||
//! println!(
|
//! println!(
|
||||||
//! "content: {}, span: {}-{}",
|
//! "content: {}, span: {}-{}",
|
||||||
//! delta.change.content, delta.change.start, delta.change.end
|
//! update.change.content, update.change.start, update.change.end
|
||||||
//! );
|
//! );
|
||||||
//! delta.ack();
|
//! buffer.ack(update.version);
|
||||||
//! } // if None, no changes are currently available
|
//! } // if None, no changes are currently available
|
||||||
//! # };
|
//! # };
|
||||||
//! ```
|
//! ```
|
||||||
|
|
Loading…
Reference in a new issue