pub struct RpField<F>where
F: Flavor + 'static,{
pub required: bool,
pub safe_ident: Option<String>,
pub ident: String,
pub comment: Vec<String>,
pub ty: F::Type,
pub field_as: Option<String>,
}
Fields§
§required: bool
Is the field required.
safe_ident: Option<String>
Mangled identifier, taking target-specific keywords into account.
ident: String
Original identifier used to specify the field.
comment: Vec<String>
Field comments.
ty: F::Type
§field_as: Option<String>
Alias of field in JSON.
Implementations§
Source§impl<F> RpField<F>where
F: Flavor + 'static,
impl<F> RpField<F>where
F: Flavor + 'static,
pub fn new<S: AsRef<str>>(ident: S, ty: F::Type) -> Self
pub fn is_optional(&self) -> bool
pub fn is_required(&self) -> bool
Sourcepub fn safe_ident(&self) -> &str
pub fn safe_ident(&self) -> &str
Get the keyword-safe identifier.
This will be the identifier escaped to avoid any target-language keywords.
Sourcepub fn with_safe_ident<S: AsRef<str>>(self, safe_ident: S) -> RpField<F>
pub fn with_safe_ident<S: AsRef<str>>(self, safe_ident: S) -> RpField<F>
Change the safe identifier.
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Get the JSON name of the field, if it differs from ident
.
TODO: Return Option
, currently returns ident. This is a better indication whether
‘renaming’ should occur.
pub fn display(&self) -> String
Trait Implementations§
Source§impl<F> FlavorField for RpField<F>where
F: Flavor + 'static,
impl<F> FlavorField for RpField<F>where
F: Flavor + 'static,
Source§fn is_discriminating(&self) -> bool
fn is_discriminating(&self) -> bool
Indicates if the field is discriminating in an untagged context.
impl<F> Eq for RpField<F>
impl<F> StructuralPartialEq for RpField<F>where
F: Flavor + 'static,
Auto Trait Implementations§
impl<F> Freeze for RpField<F>
impl<F> RefUnwindSafe for RpField<F>
impl<F> Send for RpField<F>
impl<F> Sync for RpField<F>
impl<F> Unpin for RpField<F>
impl<F> UnwindSafe for RpField<F>
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