pub struct EditCommand<T> {
pub view_id: ViewId,
pub cmd: T,
}
Expand description
A helper type, which extracts the view_id
field from edit
requests and notifications.
Edit requests and notifications have ‘method’, ‘params’, and
‘view_id’ param members. We use this wrapper, which has custom
Deserialize
and Serialize
implementations, to pull out the
view_id
field.
§Examples
extern crate serde_json;
use crate::xi_core::rpc::*;
let json = r#"{
"view_id": "view-id-1",
"method": "scroll",
"params": [0, 6]
}"#;
let cmd: EditCommand<EditNotification> = serde_json::from_str(&json).unwrap();
match cmd.cmd {
EditNotification::Scroll( .. ) => (), // expected
other => panic!("Unexpected variant {:?}", other),
}
Fields§
§view_id: ViewId
§cmd: T
Trait Implementations§
Source§impl<T: Clone> Clone for EditCommand<T>
impl<T: Clone> Clone for EditCommand<T>
Source§fn clone(&self) -> EditCommand<T>
fn clone(&self) -> EditCommand<T>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug> Debug for EditCommand<T>
impl<T: Debug> Debug for EditCommand<T>
Source§impl<'de, T: Deserialize<'de>> Deserialize<'de> for EditCommand<T>
impl<'de, T: Deserialize<'de>> Deserialize<'de> for EditCommand<T>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T: PartialEq> PartialEq for EditCommand<T>
impl<T: PartialEq> PartialEq for EditCommand<T>
Source§impl<T: Serialize> Serialize for EditCommand<T>
impl<T: Serialize> Serialize for EditCommand<T>
impl<T> StructuralPartialEq for EditCommand<T>
Auto Trait Implementations§
impl<T> Freeze for EditCommand<T>where
T: Freeze,
impl<T> RefUnwindSafe for EditCommand<T>where
T: RefUnwindSafe,
impl<T> Send for EditCommand<T>where
T: Send,
impl<T> Sync for EditCommand<T>where
T: Sync,
impl<T> Unpin for EditCommand<T>where
T: Unpin,
impl<T> UnwindSafe for EditCommand<T>where
T: UnwindSafe,
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