pub struct DeprecatedField {
pub field_name: String,
pub replacement: Option<String>,
}Expand description
A transparent wrapper that marks a schema field as deprecated in the
generated OpenAPI output.
The inner value is the field name (a string) that is being deprecated. Optionally carries a replacement hint shown in documentation.
Serializes/deserializes the field name transparently.
§Examples
use api_bones::openapi::DeprecatedField;
let d = DeprecatedField::new("legacy_id").with_replacement("resource_id");
assert_eq!(d.field_name(), "legacy_id");
assert_eq!(d.replacement(), Some("resource_id"));Fields§
§field_name: StringThe name of the deprecated field.
replacement: Option<String>Optional migration hint pointing to the replacement field or endpoint.
Implementations§
Source§impl DeprecatedField
impl DeprecatedField
Sourcepub fn new(field_name: impl Into<String>) -> Self
pub fn new(field_name: impl Into<String>) -> Self
Create a new DeprecatedField marker.
§Examples
use api_bones::openapi::DeprecatedField;
let d = DeprecatedField::new("old_id");
assert_eq!(d.field_name(), "old_id");
assert!(d.replacement().is_none());Sourcepub fn with_replacement(self, replacement: impl Into<String>) -> Self
pub fn with_replacement(self, replacement: impl Into<String>) -> Self
Attach a replacement hint (builder-style).
§Examples
use api_bones::openapi::DeprecatedField;
let d = DeprecatedField::new("old_id").with_replacement("resource_id");
assert_eq!(d.replacement(), Some("resource_id"));Sourcepub fn field_name(&self) -> &str
pub fn field_name(&self) -> &str
The deprecated field name.
Sourcepub fn replacement(&self) -> Option<&str>
pub fn replacement(&self) -> Option<&str>
The optional replacement hint.
Trait Implementations§
Source§impl Clone for DeprecatedField
impl Clone for DeprecatedField
Source§fn clone(&self) -> DeprecatedField
fn clone(&self) -> DeprecatedField
Returns a duplicate 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 DeprecatedField
impl Debug for DeprecatedField
Source§impl<'de> Deserialize<'de> for DeprecatedField
impl<'de> Deserialize<'de> for DeprecatedField
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 DeprecatedField
impl PartialEq for DeprecatedField
Source§impl Serialize for DeprecatedField
impl Serialize for DeprecatedField
impl Eq for DeprecatedField
impl StructuralPartialEq for DeprecatedField
Auto Trait Implementations§
impl Freeze for DeprecatedField
impl RefUnwindSafe for DeprecatedField
impl Send for DeprecatedField
impl Sync for DeprecatedField
impl Unpin for DeprecatedField
impl UnsafeUnpin for DeprecatedField
impl UnwindSafe for DeprecatedField
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