pub struct ListPatch<S> { /* private fields */ }Expand description
Item changes to list signals of S, sent without the rest of each list.
Build one with Sig::patch_append, Sig::patch_prepend,
Sig::patch_upsert, or Sig::patch_remove, and combine with
ListPatch::and. The browser applies the changes in order to the list
it holds, so a list the server sends one message of at a time grows in
the browser without the server keeping a copy of it.
use hypersig::{Patches, Signals};
use serde::{Deserialize, Serialize};
#[derive(Signals, Serialize, Deserialize)]
struct Message {
body: String,
}
#[derive(Signals, Serialize, Deserialize)]
struct Room {
messages: Vec<Message>,
}
let hello = Message { body: "hello".into() };
let patches: Patches<Room> = Room::messages().patch_append(&[hello]).into();
assert_eq!(
patches.to_event_stream(),
"event: hs-list\ndata: [\"append\",\"messages\",[\"lit\",[{\"body\":\"hello\"}]]]\n\n",
);Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for ListPatch<S>
impl<S> RefUnwindSafe for ListPatch<S>
impl<S> Send for ListPatch<S>
impl<S> Sync for ListPatch<S>
impl<S> Unpin for ListPatch<S>
impl<S> UnsafeUnpin for ListPatch<S>
impl<S> UnwindSafe for ListPatch<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more