Enum CoreNotification

Source
pub enum CoreNotification {
    Edit(EditCommand<EditNotification>),
    Plugin(PluginNotification),
    CloseView {
        view_id: ViewId,
    },
    Save {
        view_id: ViewId,
        file_path: String,
    },
    SetTheme {
        theme_name: String,
    },
    ClientStarted {
        config_dir: Option<PathBuf>,
        client_extras_dir: Option<PathBuf>,
    },
    ModifyUserConfig {
        domain: ConfigDomainExternal,
        changes: Table,
    },
    TracingConfig {
        enabled: bool,
    },
    SaveTrace {
        destination: PathBuf,
        frontend_samples: Value,
    },
    SetLanguage {
        view_id: ViewId,
        language_id: LanguageId,
    },
}
Expand description

The notifications which make up the base of the protocol.

§Note

For serialization, all identifiers are converted to “snake_case”.

§Examples

The close_view command:

extern crate serde_json;
use crate::xi_core::rpc::CoreNotification;

let json = r#"{
    "method": "close_view",
    "params": { "view_id": "view-id-1" }
    }"#;

let cmd: CoreNotification = serde_json::from_str(&json).unwrap();
match cmd {
    CoreNotification::CloseView { .. } => (), // expected
    other => panic!("Unexpected variant"),
}

The client_started command:

extern crate serde_json;
use crate::xi_core::rpc::CoreNotification;

let json = r#"{
    "method": "client_started",
    "params": {}
    }"#;

let cmd: CoreNotification = serde_json::from_str(&json).unwrap();
match cmd {
    CoreNotification::ClientStarted { .. }  => (), // expected
    other => panic!("Unexpected variant"),
}

Variants§

§

Edit(EditCommand<EditNotification>)

The ‘edit’ namespace, for view-specific editor actions.

The params object has internal method and params members, which are parsed into the appropriate EditNotification.

§Note:

All edit commands (notifications and requests) include in their inner params object a view_id field. On the xi-core side, we pull out this value during parsing, and use it for routing.

For more on the edit commands, see EditNotification and EditRequest.

§Examples

#[macro_use]
extern crate serde_json;
use crate::xi_core::rpc::*;
let edit = EditCommand {
    view_id: 1.into(),
    cmd: EditNotification::Insert { chars: "hello!".into() },
};
let rpc = CoreNotification::Edit(edit);
let expected = json!({
    "method": "edit",
    "params": {
        "method": "insert",
        "view_id": "view-id-1",
        "params": {
            "chars": "hello!",
        }
    }
});
assert_eq!(serde_json::to_value(&rpc).unwrap(), expected);
§

Plugin(PluginNotification)

The ‘plugin’ namespace, for interacting with plugins.

As with edit commands, the params object has is a nested RPC, with the name of the command included as the command field.

(this should be changed to more accurately reflect the behaviour of the edit commands).

For the available commands, see PluginNotification.

§Examples

#[macro_use]
extern crate serde_json;
use crate::xi_core::rpc::*;
let rpc = CoreNotification::Plugin(
    PluginNotification::Start {
        view_id: 1.into(),
        plugin_name: "syntect".into(),
    });

let expected = json!({
    "method": "plugin",
    "params": {
        "command": "start",
        "view_id": "view-id-1",
        "plugin_name": "syntect",
    }
});
assert_eq!(serde_json::to_value(&rpc).unwrap(), expected);
§

CloseView

Tells xi-core to close the specified view.

Fields

§view_id: ViewId
§

Save

Tells xi-core to save the contents of the specified view’s buffer to the specified path.

Fields

§view_id: ViewId
§file_path: String
§

SetTheme

Tells xi-core to set the theme.

Fields

§theme_name: String
§

ClientStarted

Notifies xi-core that the client has started.

Fields

§config_dir: Option<PathBuf>
§client_extras_dir: Option<PathBuf>

Path to additional plugins, included by the client.

§

ModifyUserConfig

Updates the user’s config for the given domain. Where keys in changes are null, those keys are cleared in the user config for that domain; otherwise the config is updated with the new value.

Note: If the client is using file-based config, the only valid domain argument is ConfigDomain::UserOverride(_), which represents non-persistent view-specific settings, such as when a user manually changes whitespace settings for a given view.

Fields

§changes: Table
§

TracingConfig

Control whether the tracing infrastructure is enabled. This propagates to all peers that should respond by toggling its own infrastructure on/off.

Fields

§enabled: bool
§

SaveTrace

Save trace data to the given path. The core will first send CoreRequest::CollectTrace to all peers to collect the samples.

Fields

§destination: PathBuf
§frontend_samples: Value
§

SetLanguage

Tells xi-core to set the language id for the view.

Fields

§view_id: ViewId
§language_id: LanguageId

Trait Implementations§

Source§

impl Debug for CoreNotification

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for CoreNotification

Source§

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 PartialEq for CoreNotification

Source§

fn eq(&self, other: &CoreNotification) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for CoreNotification

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for CoreNotification

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,