mirror of
https://github.com/hexedtech/codemp.git
synced 2024-12-22 21:04:53 +01:00
fix: inaccessible fields, pub(crate) constructor
This commit is contained in:
parent
c20cbde833
commit
b8578a89a4
6 changed files with 34 additions and 16 deletions
|
@ -13,6 +13,16 @@ pub struct BufferController {
|
|||
stream: Mutex<broadcast::Receiver<OperationSeq>>,
|
||||
}
|
||||
|
||||
impl BufferController {
|
||||
pub(crate) fn new(
|
||||
content: watch::Receiver<String>,
|
||||
operations: mpsc::Sender<OperationSeq>,
|
||||
stream: Mutex<broadcast::Receiver<OperationSeq>>,
|
||||
) -> Self {
|
||||
BufferController { content, operations, stream }
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl OperationFactory for BufferController {
|
||||
fn content(&self) -> String {
|
||||
|
|
|
@ -51,11 +51,11 @@ impl ControllerWorker<TextChange> for BufferControllerWorker {
|
|||
type Rx = Streaming<RawOp>;
|
||||
|
||||
fn subscribe(&self) -> BufferController {
|
||||
BufferController {
|
||||
content: self.receiver.clone(),
|
||||
operations: self.sender.clone(),
|
||||
stream: Mutex::new(self.stream.subscribe()),
|
||||
}
|
||||
BufferController::new(
|
||||
self.receiver.clone(),
|
||||
self.sender.clone(),
|
||||
Mutex::new(self.stream.subscribe()),
|
||||
)
|
||||
}
|
||||
|
||||
async fn work(mut self, mut tx: Self::Tx, mut rx: Self::Rx) {
|
||||
|
|
|
@ -38,11 +38,11 @@ impl CodempClient {
|
|||
}
|
||||
|
||||
pub fn get_cursor(&self) -> Option<Arc<CursorController>> {
|
||||
Some(self.workspace?.cursor.clone())
|
||||
Some(self.workspace.as_ref()?.cursor.clone())
|
||||
}
|
||||
|
||||
pub fn get_buffer(&self, path: &str) -> Option<Arc<BufferController>> {
|
||||
self.workspace?.buffers.get(path).cloned()
|
||||
self.workspace.as_ref()?.buffers.get(path).cloned()
|
||||
}
|
||||
|
||||
pub async fn join(&mut self, _session: &str) -> Result<Arc<CursorController>, CodempError> {
|
||||
|
@ -72,7 +72,7 @@ impl CodempClient {
|
|||
}
|
||||
|
||||
pub async fn create(&mut self, path: &str, content: Option<&str>) -> Result<(), CodempError> {
|
||||
if let Some(workspace) = &self.workspace {
|
||||
if let Some(_workspace) = &self.workspace {
|
||||
self.client.buffer
|
||||
.create(BufferPayload {
|
||||
user: self.id.clone(),
|
||||
|
@ -86,7 +86,7 @@ impl CodempClient {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn attach(&mut self, path: &str, content: Option<&str>) -> Result<Arc<BufferController>, CodempError> {
|
||||
pub async fn attach(&mut self, path: &str) -> Result<Arc<BufferController>, CodempError> {
|
||||
if let Some(workspace) = &mut self.workspace {
|
||||
let mut client = self.client.buffer.clone();
|
||||
let req = BufferPayload {
|
||||
|
|
|
@ -9,6 +9,16 @@ pub struct CursorController {
|
|||
stream: Mutex<broadcast::Receiver<CursorEvent>>,
|
||||
}
|
||||
|
||||
impl CursorController {
|
||||
pub(crate) fn new(
|
||||
uid: String,
|
||||
op: mpsc::Sender<CursorEvent>,
|
||||
stream: Mutex<broadcast::Receiver<CursorEvent>>
|
||||
) -> Self {
|
||||
CursorController { uid, op, stream }
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Controller<CursorEvent> for CursorController {
|
||||
type Input = CursorPosition;
|
||||
|
|
|
@ -34,11 +34,11 @@ impl ControllerWorker<CursorEvent> for CursorControllerWorker {
|
|||
type Rx = Streaming<CursorEvent>;
|
||||
|
||||
fn subscribe(&self) -> CursorController {
|
||||
CursorController {
|
||||
uid: self.uid.clone(),
|
||||
op: self.producer.clone(),
|
||||
stream: Mutex::new(self.channel.subscribe()),
|
||||
}
|
||||
CursorController::new(
|
||||
self.uid.clone(),
|
||||
self.producer.clone(),
|
||||
Mutex::new(self.channel.subscribe())
|
||||
)
|
||||
}
|
||||
|
||||
async fn work(mut self, mut tx: Self::Tx, mut rx: Self::Rx) {
|
||||
|
|
|
@ -10,8 +10,6 @@ use crate::{
|
|||
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
const CODEMP_DEFAULT_HOST : &str = "http://alemi.dev:50051";
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref RUNTIME : Runtime = Runtime::new().expect("could not create tokio runtime");
|
||||
static ref INSTANCE : Instance = Instance::default();
|
||||
|
|
Loading…
Reference in a new issue