Skip to main content

Parser

Struct Parser 

Source
pub struct Parser<R> { /* private fields */ }

Implementations§

Source§

impl<R> Parser<R>

Source

pub fn parse_one(&mut self, ims: &[u8]) -> Result<(), KERIError>

Parse one message from a byte array synchronously This is the Rust equivalent of Python’s parseOne method

Source

pub fn new(reader: R, framed: bool, pipeline: bool, handlers: Handlers) -> Self

Source

pub fn without_handlers( reader: R, framed: bool, pipeline: bool, local: bool, ) -> Self

Create a parser with no handlers. It can only extract messages (see Parser::parse_messages); the caller routes them. This is how a single owner (e.g. Habery) parses without the parser holding shared references to its Kevery/Revery.

Source

pub fn parse_messages(&mut self, ims: &[u8]) -> Result<Vec<Message>, KERIError>

Parse every complete message in ims and return them without dispatching to any handler. Errors if ims ends mid-message.

Source

pub fn _extractor<T: Parsable>( &mut self, cold: &str, abort: bool, _gvrsn: &Versionage, ) -> Result<T, MatterError>

Returns a Result containing an instance of the provided type T from the input message stream.

§Parameters
  • ims - A mutable reference to bytes that can be stripped
  • cold - Stream state indicator (txt or bny)
  • abort - True means abort if bad pipelined frame, False means wait for more data
  • gvrsn - Instance of genera version of CESR code tables
§Returns
  • Result<T, MatterError> - Either the successfully parsed instance or an error
§Errors
  • ColdStartError - If the stream state is invalid
  • ShortageError - If not enough bytes in stream and abort is true
§Type Parameters
  • T - A type that implements the Parsable trait (equivalent to Serder, Counter, Matter, Indexer)
Source

pub fn sad_path_sig_group( &mut self, ctr: &BaseCounter, root: Option<&Pather>, cold: &str, pipelined: bool, gvrsn: &Versionage, ) -> Result<Vec<SadPathGroup>, MatterError>

Extract sad path signature groups

§Parameters
  • ctr - Group type counter
  • ims - Serialized incoming message stream
  • root - Optional root path of this group
  • cold - Next character Coldage type indicator
  • pipelined - Whether to use pipeline processor
§Returns
  • Vector of tuples containing extracted sad path signature groups
Source

pub fn trans_idx_sig_groups( &mut self, ctr: &BaseCounter, cold: &str, pipelined: bool, gvrsn: &Versionage, ) -> Result<Vec<Tsgs>, MatterError>

Extract attached trans indexed sig groups, each made of:

  • triple pre+snu+dig plus indexed sig group
  • pre is pre of signer (endorser) of msg
  • snu is sn of signer’s est evt when signed
  • dig is dig of signer’s est event when signed Followed by counter for ControllerIdxSigs with attached indexed sigs from trans signer (endorser).
§Parameters
  • ctr - Group type counter
  • ims - Serialized incoming message stream
  • cold - Next character Coldage type indicator
  • pipelined - Whether to use pipeline processor
§Returns
  • Vector of tuples containing (prefixer, seqner, saider, isigers)
Source

pub fn non_trans_receipt_couples( &mut self, ctr: &BaseCounter, cold: &str, pipelined: bool, gvrsn: &Versionage, ) -> Result<Vec<Cigar>, MatterError>

Extract attached receipt couplets into a vector of cigars Verfer property of each cigar is the identifier prefix Cigar itself has the attached signature

§Parameters
  • ctr - Counter with count field indicating number of attachments
  • ims - Input stream containing serialized message data
  • cold - Character coldage type indicator
  • pipelined - Whether to use pipeline processor for stream
§Returns
  • Vector of Cigar objects with attached verfers
Source§

impl<R: AsyncRead + Unpin + Send> Parser<R>

Source

pub async fn parse_stream( &mut self, once: Option<bool>, ) -> Result<(), KERIError>

Auto Trait Implementations§

§

impl<R> !RefUnwindSafe for Parser<R>

§

impl<R> !UnwindSafe for Parser<R>

§

impl<R> Freeze for Parser<R>
where R: Freeze,

§

impl<R> Send for Parser<R>
where R: Send,

§

impl<R> Sync for Parser<R>
where R: Sync,

§

impl<R> Unpin for Parser<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for Parser<R>
where R: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more