|
|
|
@ -73,6 +73,7 @@ impl State
|
|
|
|
|
/// Insert a new post
|
|
|
|
|
pub async fn insert_new_post(&self, post: Post) -> SharedPost
|
|
|
|
|
{
|
|
|
|
|
todo!("Rewrite");
|
|
|
|
|
let mut onee = self.0.oneesan.write().await;
|
|
|
|
|
let id = *post.post_id();
|
|
|
|
|
|
|
|
|
@ -90,9 +91,12 @@ impl State
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Consume into a stream that yields all users lazily.
|
|
|
|
|
///
|
|
|
|
|
/// # Locks
|
|
|
|
|
/// The stream producer holds the Oneesan *read* lock until the stream is consumed or dropped.
|
|
|
|
|
pub fn all_users_stream(self: Arc<Self>) -> impl Stream<Item=SharedUser>
|
|
|
|
|
{
|
|
|
|
|
let (mut tx, rx) = mpsc::channel(1);
|
|
|
|
|
let (mut tx, rx) = mpsc_channel!(defaults::STATE_STREAM_BUFFER_SIZE);
|
|
|
|
|
tokio::spawn(async move {
|
|
|
|
|
let onee = self.0.oneesan.read().await;
|
|
|
|
|
for (_, user) in onee.users.iter()
|
|
|
|
@ -106,9 +110,12 @@ impl State
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Consume into a stream that yields all posts lazily.
|
|
|
|
|
///
|
|
|
|
|
/// # Locks
|
|
|
|
|
/// The stream producer holds the Oneesan *read* lock until the stream is consumed or dropped.
|
|
|
|
|
pub fn all_posts_stream(self: Arc<Self>) -> impl Stream<Item=SharedPost>
|
|
|
|
|
{
|
|
|
|
|
let (mut tx, rx) = mpsc::channel(1);
|
|
|
|
|
let (mut tx, rx) = mpsc_channel!(defaults::STATE_STREAM_BUFFER_SIZE);
|
|
|
|
|
tokio::spawn(async move {
|
|
|
|
|
let onee = self.0.oneesan.read().await;
|
|
|
|
|
for (_, post) in onee.posts.iter()
|
|
|
|
|