Rename workspace packages and update Rust imports and usage examples

This commit is contained in:
2026-12-03 04:27:32 +08:00
parent ef251ae339
commit 01b8af4757
16 changed files with 56 additions and 55 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
[package]
name = "telefind-app"
name = "app"
version.workspace = true
edition.workspace = true
default-run = "telefind"
@@ -9,8 +9,8 @@ name = "telefind"
path = "src/main.rs"
[dependencies]
telefind-core = { path = "../core" }
telefind-bot = { path = "../bot" }
core = { path = "../core" }
bot = { path = "../bot" }
ureq = { version = "3", features = ["json"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
+1 -1
View File
@@ -1,7 +1,7 @@
//! Line-delimited public document changes supplied by the caller.
use search_core::{Document, DocumentId, Media, PublicName, SearchIndex};
use serde::Deserialize;
use std::{error::Error, io::BufRead};
use telefind_core::{Document, DocumentId, Media, PublicName, SearchIndex};
#[derive(Deserialize)]
#[serde(rename_all = "lowercase")]
+3 -3
View File
@@ -1,3 +1,5 @@
use app::{input, telegram};
use search_core::MemoryIndex;
use std::{
env,
error::Error,
@@ -5,8 +7,6 @@ use std::{
io::{self, BufReader},
process::ExitCode,
};
use telefind_app::{input, telegram};
use telefind_core::MemoryIndex;
const USAGE: &str = concat!(
"telefind bot [events.jsonl|-]\n",
@@ -36,7 +36,7 @@ fn run() -> Result<(), Box<dyn Error>> {
}
Some("query") if args.len() >= 3 => {
load(&args[1], &mut index)?;
let reply = telefind_bot::handle(&index, "telefind", &args[2..].join(" "))?;
let reply = bot::handle(&index, "telefind", &args[2..].join(" "))?;
println!("{}", serde_json::to_string(&telegram::render(reply))?);
Ok(())
}
+1 -1
View File
@@ -6,10 +6,10 @@ use self::{
update::{dispatch, Update},
};
pub use client::Client;
use search_core::SearchIndex;
use serde::Deserialize;
use serde_json::{json, Value};
use std::{error::Error, thread, time::Duration};
use telefind_core::SearchIndex;
pub use update::render;
fn with_retry<T>(
+1 -1
View File
@@ -1,8 +1,8 @@
//! Broker-neutral gateway and leased workers. Each adapter is scoped to one bot.
use super::{client::Failure, process, receive, run_loop, Client, Update};
use search_core::SearchIndex;
use serde::{Deserialize, Serialize};
use std::{error::Error, time::Duration};
use telefind_core::SearchIndex;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Lane {
+2 -2
View File
@@ -1,9 +1,9 @@
use super::*;
use search_core::MemoryIndex;
use std::{
io::{BufRead, BufReader, Read, Write},
net::TcpListener,
};
use telefind_core::MemoryIndex;
fn respond(server: &TcpListener, reply: impl FnOnce(&str, Value) -> (u16, String)) {
let (mut socket, _) = server.accept().unwrap();
@@ -105,7 +105,7 @@ fn nonpublic_and_protected_updates_do_not_add_searchable_posts() {
}
assert_eq!(
index
.search(&telefind_core::Query::new("private"))
.search(&search_core::Query::new("private"))
.unwrap()
.total,
0
+1 -1
View File
@@ -108,7 +108,7 @@ fn publish_failure_keeps_offset_then_workers_replay_and_defer_flooded_reply() {
assert_eq!(step(&mut queries), Outcome::Completed);
assert_eq!(
index
.search(&telefind_core::Query::new("tutorial"))
.search(&search_core::Query::new("tutorial"))
.unwrap()
.total,
0
+2 -2
View File
@@ -1,7 +1,7 @@
use bot::{handle, Reply};
use search_core::{Document, DocumentId, Media, PublicName, SearchIndex};
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use telefind_bot::{handle, Reply};
use telefind_core::{Document, DocumentId, Media, PublicName, SearchIndex};
#[derive(Deserialize, Serialize)]
pub struct Update {
+2 -2
View File
@@ -1,7 +1,7 @@
[package]
name = "telefind-bot"
name = "bot"
version.workspace = true
edition.workspace = true
[dependencies]
telefind-core = { path = "../core" }
core = { path = "../core" }
+1 -1
View File
@@ -1,4 +1,4 @@
use telefind_core::{Kind, Media, Query};
use search_core::{Kind, Media, Query};
pub(crate) enum Input<'a> {
Ignore,
Help,
+1 -1
View File
@@ -1,7 +1,7 @@
//! Transport-independent Telegram search interaction. The host supplies
//! incoming text and sends the returned plain-text labels and URL buttons.
mod command;
use telefind_core::{Document, Kind, SearchIndex};
use search_core::{Document, Kind, SearchIndex};
#[derive(Debug, PartialEq)]
pub struct ResultLink {
+4 -4
View File
@@ -1,5 +1,5 @@
use telefind_bot::{handle, Reply};
use telefind_core::{Document, DocumentId, MemoryIndex, PublicName, SearchIndex};
use bot::{handle, Reply};
use search_core::{Document, DocumentId, MemoryIndex, PublicName, SearchIndex};
#[test]
fn plain_and_addressed_search_return_public_post_link() {
@@ -72,7 +72,7 @@ fn paging_is_stateless_and_rejects_invalid_numbers() {
#[test]
fn type_filter_is_available_in_search_and_page_commands() {
let mut index = MemoryIndex::default();
for (id, media) in [(1, None), (2, Some(telefind_core::Media::Video))] {
for (id, media) in [(1, None), (2, Some(search_core::Media::Video))] {
index
.upsert(Document {
id: DocumentId::Post {
@@ -117,7 +117,7 @@ fn scoped_media_search_keeps_quoted_phrase_and_original_link() {
username: PublicName::new("my_feed").unwrap(),
title: String::new(),
body: body.into(),
media: Some(telefind_core::Media::Video),
media: Some(search_core::Media::Video),
})
.unwrap();
}
+4 -1
View File
@@ -1,8 +1,11 @@
[package]
name = "telefind-core"
name = "core"
version.workspace = true
edition.workspace = true
[lib]
name = "search_core"
[dependencies]
jieba-rs = "0.8"
unicode-normalization = "0.1"
+1 -3
View File
@@ -1,6 +1,4 @@
use telefind_core::{
Document, DocumentId, Kind, Media, MemoryIndex, PublicName, Query, SearchIndex,
};
use search_core::{Document, DocumentId, Kind, Media, MemoryIndex, PublicName, Query, SearchIndex};
fn post(chat: i64, message: u32, title: &str, body: &str) -> Document {
Document {