Enum OrdParser

Source
pub enum OrdParser {
    Ordinal(Nft),
    Brc20(Brc20),
}
Expand description

Encapsulates inscription parsing logic for both Ordinals and BRC20s.

Variants§

§

Ordinal(Nft)

Denotes a parsed Nft inscription.

§

Brc20(Brc20)

Denotes a parsed Brc20 inscription.

Implementations§

Source§

impl OrdParser

Source

pub fn parse_all(tx: &Transaction) -> OrdResult<Vec<(InscriptionId, Self)>>

Parses all inscriptions from a given transaction and categorizes them as either Self::Brc20 or Self::Ordinal.

This function extracts all inscription data from the transaction, attempts to parse each inscription, and returns a vector of categorized inscriptions with their corresponding IDs.

§Errors

Will return an error if any inscription data cannot be parsed correctly, or if no valid inscriptions are found in the transaction.

Source

pub fn parse_one( tx: &Transaction, index: usize, ) -> OrdResult<(InscriptionId, Self)>

Parses a single inscription from a transaction at a specified index, returning the parsed inscription along with its ID.

This method specifically targets one inscription identified by its index within the transaction’s inputs. It extracts the inscription data, attempts to parse it, and categorizes it as either Self::Brc20 or Self::Ordinal.

§Errors

Returns an error if the inscription data at the specified index cannot be parsed, if there is no data at the specified index, or if the data at the index does not contain a valid payload.

Trait Implementations§

Source§

impl Clone for OrdParser

Source§

fn clone(&self) -> OrdParser

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OrdParser

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for OrdParser

Source§

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 From<Brc20> for OrdParser

Source§

fn from(inscription: Brc20) -> Self

Converts to this type from the input type.
Source§

impl From<Nft> for OrdParser

Source§

fn from(inscription: Nft) -> Self

Converts to this type from the input type.
Source§

impl Inscription for OrdParser

Source§

fn content_type(&self) -> String

Returns the MIME content type of the inscription. Read more
Source§

fn data(&self) -> OrdResult<PushBytesBuf>

Returns the body of the inscription as to be pushed to the redeem script. Read more
Source§

fn generate_redeem_script( &self, builder: ScriptBuilder, pubkey: RedeemScriptPubkey, ) -> OrdResult<ScriptBuilder>

Generates the redeem script from a script pubkey and the inscription. Read more
Source§

fn encode(&self) -> OrdResult<String>
where Self: Serialize,

Encodes the inscription object into a JSON string. Read more
Source§

fn parse(data: &[u8]) -> OrdResult<Self>
where Self: Sized,

Parses inscription data from the serialized bytes found in the witness script. Read more
Source§

impl PartialEq for OrdParser

Source§

fn eq(&self, other: &OrdParser) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for OrdParser

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<&OrdParser> for Brc20

Source§

type Error = OrdError

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

fn try_from(parser: &OrdParser) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&OrdParser> for Nft

Source§

type Error = OrdError

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

fn try_from(parser: &OrdParser) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<OrdParser> for Brc20

Source§

type Error = OrdError

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

fn try_from(parser: OrdParser) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<OrdParser> for Nft

Source§

type Error = OrdError

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

fn try_from(parser: OrdParser) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for OrdParser

Source§

impl StructuralPartialEq for OrdParser

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,