mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-05 12:14:43 +00:00
chore: rm loro py (#601)
This commit is contained in:
parent
c7c1e2fa89
commit
46bab49281
4 changed files with 0 additions and 69 deletions
|
@ -1,12 +0,0 @@
|
|||
[package]
|
||||
name = "pyloro"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
publish = false
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
pyo3 = { version = "0.17", features = ["extension-module"] }
|
||||
loro-internal = { path = "../loro-internal" }
|
|
@ -1,7 +0,0 @@
|
|||
# loro-python
|
||||
|
||||
```bash
|
||||
pip3 install maturin
|
||||
maturin build # or python3 -m maturin build
|
||||
|
||||
```
|
|
@ -1,6 +0,0 @@
|
|||
from pyloro import Loro, LoroText;
|
||||
|
||||
loro = Loro()
|
||||
text = loro.get_text("text")
|
||||
text.insert(loro, 0, "123")
|
||||
print(text.value())
|
|
@ -1,44 +0,0 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use loro_internal::{LoroDoc, TextHandler};
|
||||
use pyo3::prelude::*;
|
||||
|
||||
#[pyclass]
|
||||
struct Loro(LoroDoc);
|
||||
|
||||
#[pyclass]
|
||||
struct LoroText(TextHandler);
|
||||
|
||||
#[pymethods]
|
||||
impl Loro {
|
||||
#[new]
|
||||
pub fn __new__() -> Self {
|
||||
Self(LoroDoc::default())
|
||||
}
|
||||
|
||||
pub fn get_text(&mut self, id: &str) -> LoroText {
|
||||
let text = self.0.get_text(id);
|
||||
LoroText(text)
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl LoroText {
|
||||
pub fn insert(&mut self, ctx: &Loro, pos: usize, value: &str) -> PyResult<()> {
|
||||
self.0
|
||||
.insert_with_txn(&mut ctx.0.txn().unwrap(), pos, value)
|
||||
.unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn value(&self) -> String {
|
||||
Arc::try_unwrap(self.0.get_value().into_string().unwrap()).unwrap_or_else(|x| (*x).clone())
|
||||
}
|
||||
}
|
||||
|
||||
#[pymodule]
|
||||
fn pyloro(_py: Python, m: &PyModule) -> PyResult<()> {
|
||||
m.add_class::<Loro>()?;
|
||||
m.add_class::<LoroText>()?;
|
||||
Ok(())
|
||||
}
|
Loading…
Reference in a new issue