pub(crate) struct NetdocEncoder {
built: Result<String, Bug>,
}
hs-service
only.Expand description
Encoder, representing a partially-built document.
For example usage, see the tests in this module, or a descriptor building
function in tor-netdoc (such as hsdesc::build::inner::HsDescInner::build_sign
).
Fields§
§built: Result<String, Bug>
The being-built document, with everything accumulated so far
If an ItemEncoder
exists, it will add a newline when it’s dropped.
Err
means bad values passed to some builder function
Implementations§
Source§impl NetdocEncoder
impl NetdocEncoder
Sourcepub(crate) fn item(&mut self, keyword: impl Keyword) -> ItemEncoder<'_>
pub(crate) fn item(&mut self, keyword: impl Keyword) -> ItemEncoder<'_>
Adds an item to the being-built document
The item can be further extended with arguments or an object,
using the returned ItemEncoder
.
Sourcefn write_with(&mut self, f: impl FnOnce(&mut String) -> Result<(), Bug>)
fn write_with(&mut self, f: impl FnOnce(&mut String) -> Result<(), Bug>)
Extend the being-built document with a fallible function f
Doesn’t call f
if the building has already failed,
and handles the error if f
fails.
Sourcepub(crate) fn push_raw_string(&mut self, s: &dyn Display)
pub(crate) fn push_raw_string(&mut self, s: &dyn Display)
Adds raw text to the being-built document
s
is added as raw text, after the newline ending the previous item.
If item
is subsequently called, the start of that item
will immediately follow s
.
It is the responsibility of the caller to obey the metadocument syntax.
In particular, s
should end with a newline.
No checks are performed.
Incorrect use might lead to malformed documents, or later errors.
Sourcepub(crate) fn cursor(&self) -> Cursor
pub(crate) fn cursor(&self) -> Cursor
Return a cursor, pointing to just after the last item (if any)
Trait Implementations§
Source§impl Clone for NetdocEncoder
impl Clone for NetdocEncoder
Source§fn clone(&self) -> NetdocEncoder
fn clone(&self) -> NetdocEncoder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for NetdocEncoder
impl !RefUnwindSafe for NetdocEncoder
impl Send for NetdocEncoder
impl Sync for NetdocEncoder
impl Unpin for NetdocEncoder
impl !UnwindSafe for NetdocEncoder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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