pub struct ShExFormatter { /* private fields */ }
Expand description
Struct that can be used to pretty print ShEx schemas
Example:
use shex_compact::ShExFormatter;
use shex_ast::{Schema, ShapeExprLabel, ShapeExpr};
use iri_s::IriS;
let mut schema = Schema::new();
schema.add_prefix("ex", &IriS::new_unchecked("http://example.org/"));
schema.add_shape(ShapeExprLabel::iri_unchecked("http://example.org/S"), ShapeExpr::empty_shape(), false);
let expected = r#"prefix ex: <http://example.org/>
ex:S { }"#;
assert_eq!(ShExFormatter::default().format_schema(&schema), expected);
Implementations§
Source§impl ShExFormatter
impl ShExFormatter
pub fn keyword_color(&self) -> Option<Color>
pub fn prefix_color(&self) -> Option<Color>
pub fn semicolon_color(&self) -> Option<Color>
pub fn localname_color(&self) -> Option<Color>
pub fn with_keyword_color(self, color: Option<Color>) -> ShExFormatter
pub fn with_prefix_color(self, color: Option<Color>) -> ShExFormatter
pub fn with_semicolon_color(self, color: Option<Color>) -> ShExFormatter
pub fn with_string_color(self, color: Option<Color>) -> ShExFormatter
pub fn with_localname_color(self, color: Option<Color>) -> ShExFormatter
Sourcepub fn without_colors(self) -> ShExFormatter
pub fn without_colors(self) -> ShExFormatter
Changes the formatter to avoid showing colors
pub fn format_schema(&self, schema: &Schema) -> String
pub fn write_schema<W: Write>( &self, schema: &Schema, writer: &mut W, ) -> Result<(), Error>
Trait Implementations§
Source§impl Clone for ShExFormatter
impl Clone for ShExFormatter
Source§fn clone(&self) -> ShExFormatter
fn clone(&self) -> ShExFormatter
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 Debug for ShExFormatter
impl Debug for ShExFormatter
Auto Trait Implementations§
impl Freeze for ShExFormatter
impl RefUnwindSafe for ShExFormatter
impl Send for ShExFormatter
impl Sync for ShExFormatter
impl Unpin for ShExFormatter
impl UnwindSafe for ShExFormatter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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