pub struct TraitEntity {
pub name: String,
pub visibility: String,
pub line_start: usize,
pub line_end: usize,
pub is_protocol: bool,
pub is_abc: bool,
pub required_methods: Vec<String>,
pub doc_comment: Option<String>,
pub attributes: Vec<String>,
}Expand description
Represents a Python Protocol or Abstract Base Class (trait-like entity)
Fields§
§name: StringTrait/Protocol name
visibility: StringVisibility: “public” or “private”
line_start: usizeStarting line number (1-indexed)
line_end: usizeEnding line number (1-indexed)
is_protocol: boolIs this a Protocol (typing.Protocol)?
is_abc: boolIs this an Abstract Base Class (abc.ABC)?
required_methods: Vec<String>Method signatures required by this trait
doc_comment: Option<String>Documentation string (docstring)
attributes: Vec<String>Decorators applied
Implementations§
Source§impl TraitEntity
impl TraitEntity
Sourcepub fn new(name: impl Into<String>, line_start: usize, line_end: usize) -> Self
pub fn new(name: impl Into<String>, line_start: usize, line_end: usize) -> Self
Create a new trait entity
Sourcepub fn set_protocol(self, is_protocol: bool) -> Self
pub fn set_protocol(self, is_protocol: bool) -> Self
Set as a Protocol
Sourcepub fn add_required_method(self, method: impl Into<String>) -> Self
pub fn add_required_method(self, method: impl Into<String>) -> Self
Add a required method
Sourcepub fn set_doc_comment(self, doc: Option<String>) -> Self
pub fn set_doc_comment(self, doc: Option<String>) -> Self
Set the docstring
Sourcepub fn add_attribute(self, attr: impl Into<String>) -> Self
pub fn add_attribute(self, attr: impl Into<String>) -> Self
Add a decorator
Trait Implementations§
Source§impl Clone for TraitEntity
impl Clone for TraitEntity
Source§fn clone(&self) -> TraitEntity
fn clone(&self) -> TraitEntity
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 TraitEntity
impl Debug for TraitEntity
Source§impl<'de> Deserialize<'de> for TraitEntity
impl<'de> Deserialize<'de> for TraitEntity
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 TraitEntity
impl PartialEq for TraitEntity
Source§impl Serialize for TraitEntity
impl Serialize for TraitEntity
impl StructuralPartialEq for TraitEntity
Auto Trait Implementations§
impl Freeze for TraitEntity
impl RefUnwindSafe for TraitEntity
impl Send for TraitEntity
impl Sync for TraitEntity
impl Unpin for TraitEntity
impl UnwindSafe for TraitEntity
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