pub struct Component(/* private fields */);Expand description
A JSON text component, built field by field.
use rift_plugin::text::Component;
let invite = Component::text("Alex invited you. ")
.extra(Component::text("[Accept]").color("green").bold().run_command("/party accept Alex"));
assert_eq!(
serde_json::Value::from(invite),
serde_json::json!({
"text": "Alex invited you. ",
"extra": [{
"text": "[Accept]", "color": "green", "bold": true,
"click_event": {"action": "run_command", "command": "/party accept Alex"},
}],
})
);Implementations§
Source§impl Component
impl Component
Sourcepub fn underlined(self) -> Self
pub fn underlined(self) -> Self
Underlined text.
Sourcepub fn strikethrough(self) -> Self
pub fn strikethrough(self) -> Self
Struck-through text.
Sourcepub fn obfuscated(self) -> Self
pub fn obfuscated(self) -> Self
Obfuscated (scrambling) text.
Sourcepub fn run_command(self, command: impl Into<String>) -> Self
pub fn run_command(self, command: impl Into<String>) -> Self
A click runs command (with its leading /) as the player.
Sourcepub fn suggest_command(self, command: impl Into<String>) -> Self
pub fn suggest_command(self, command: impl Into<String>) -> Self
A click puts command into the player’s chat box.
Sourcepub fn open_url(self, url: impl Into<String>) -> Self
pub fn open_url(self, url: impl Into<String>) -> Self
A click opens url (http or https) after a confirmation.
Sourcepub fn copy_to_clipboard(self, text: impl Into<String>) -> Self
pub fn copy_to_clipboard(self, text: impl Into<String>) -> Self
A click copies text to the clipboard.
Sourcepub fn hover_text(self, text: impl Into<String>) -> Self
pub fn hover_text(self, text: impl Into<String>) -> Self
Hover text shown as written.
Sourcepub fn insertion(self, text: impl Into<String>) -> Self
pub fn insertion(self, text: impl Into<String>) -> Self
Text inserted into the chat box on shift-click.
Sourcepub fn extra(self, child: impl Into<Value>) -> Self
pub fn extra(self, child: impl Into<Value>) -> Self
Appends a child: a Component, an authoring object or a string
shown as written. Children inherit this component’s style.
Trait Implementations§
impl StructuralPartialEq for Component
Auto Trait Implementations§
impl Forget for Component
impl Freeze for Component
impl Move for Component
impl RefUnwindSafe for Component
impl Send for Component
impl Sync for Component
impl Unpin for Component
impl UnsafeUnpin for Component
impl UnwindSafe for Component
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