pub struct JsonViewer { /* private fields */ }
Expand description
A widget for viewing json
data.
Set an initial value during construction (via new
) and replace it either using update
or reset
.
The widgets provides multiple interaction points, for example to fold or unfold structures, or
to grow or shrink the number of elements shown of an array. At any time, one of these knobs is
active. Use select_next
or select_previous
or the Scrollable
implementation to change it.
Call toggle_active_element
to interact with the currently active element.
Interacting with an element might hide it, but the widget takes care to select another element
in that case.
Implementations§
Source§impl JsonViewer
impl JsonViewer
Sourcepub fn new(value: impl Value) -> Self
pub fn new(value: impl Value) -> Self
Create a new JsonViewer
widget that will display the specified value.
It follows that it is impossible to not have content. However, it is possible to show an empty String, so there is that.
Sourcepub fn reset(&mut self, value: impl Value)
pub fn reset(&mut self, value: impl Value)
Set a new value to display and do not highlight any changes (in contrast to update
).
Sourcepub fn update(&mut self, value: impl Value)
pub fn update(&mut self, value: impl Value)
Set a new value to display and highlight changes from the previous value (which will be
shown until the next update
or reset
.
Sourcepub fn select_next(&mut self) -> Result<(), ()>
pub fn select_next(&mut self) -> Result<(), ()>
Select the next interaction point of the widget (generally “down” from the current one).
Sourcepub fn select_previous(&mut self) -> Result<(), ()>
pub fn select_previous(&mut self) -> Result<(), ()>
Select the previous interaction point of the widget (generally “up” from the current one).
Sourcepub fn toggle_active_element(&mut self) -> Result<(), ()>
pub fn toggle_active_element(&mut self) -> Result<(), ()>
Interact with the currently active interaction point and, for example, fold/unfold structures.
pub fn as_widget<'a>(&'a self) -> JsonViewerWidget<'a>
Trait Implementations§
Source§impl Scrollable for JsonViewer
impl Scrollable for JsonViewer
fn scroll_forwards(&mut self) -> OperationResult
fn scroll_backwards(&mut self) -> OperationResult
fn scroll_to_beginning(&mut self) -> Result<(), ()>
fn scroll_to_end(&mut self) -> Result<(), ()>
Auto Trait Implementations§
impl Freeze for JsonViewer
impl RefUnwindSafe for JsonViewer
impl Send for JsonViewer
impl Sync for JsonViewer
impl Unpin for JsonViewer
impl UnwindSafe for JsonViewer
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more