pub struct ScriptBytes(/* private fields */);
Implementations§
Source§impl ScriptBytes
impl ScriptBytes
Sourcepub fn from_unsafe(script_bytes: Vec<u8>) -> ScriptBytes
pub fn from_unsafe(script_bytes: Vec<u8>) -> ScriptBytes
Constructs script object assuming the script length is less than 4GB. Panics otherwise.
Sourcepub fn push_slice(&mut self, data: &[u8])
pub fn push_slice(&mut self, data: &[u8])
Adds instructions to push some arbitrary data onto the stack.
§Panics
The method panics if data
length is greater or equal to
0x100000000.
Sourcepub fn len_for_slice(len: usize) -> usize
pub fn len_for_slice(len: usize) -> usize
Computes the sum of len
and the length of an appropriate push
opcode.
pub fn len_var_int(&self) -> VarInt
pub fn into_vec(self) -> Vec<u8> ⓘ
Methods from Deref<Target = Confined<Vec<u8>, 0, bc::::coding::VarIntBytes::{constant#1}>>§
Sourcepub fn iter_mut(&'c mut self) -> <&'c mut C as IntoIterator>::IntoIter
pub fn iter_mut(&'c mut self) -> <&'c mut C as IntoIterator>::IntoIter
Returns an iterator that allows modifying each value.
The iterator yields all items from start to end.
Sourcepub fn values_mut(
&mut self,
) -> impl Iterator<Item = &mut <C as KeyedCollection>::Value>
pub fn values_mut( &mut self, ) -> impl Iterator<Item = &mut <C as KeyedCollection>::Value>
Returns an iterator that allows modifying each value for each key.
Sourcepub fn keyed_values_mut(
&mut self,
) -> impl Iterator<Item = (&<C as KeyedCollection>::Key, &mut <C as KeyedCollection>::Value)>
pub fn keyed_values_mut( &mut self, ) -> impl Iterator<Item = (&<C as KeyedCollection>::Key, &mut <C as KeyedCollection>::Value)>
Returns an iterator that allows modifying each value for each key.
Sourcepub fn as_inner(&self) -> &C
👎Deprecated since 4.7.0: use as_unconfined method
pub fn as_inner(&self) -> &C
Returns inner collection type
Sourcepub fn as_unconfined(&self) -> &C
pub fn as_unconfined(&self) -> &C
Returns reference to the inner collection type.
Sourcepub fn to_inner(&self) -> Cwhere
C: Clone,
👎Deprecated since 4.7.0: use to_unconfined method
pub fn to_inner(&self) -> Cwhere
C: Clone,
Clones inner collection type and returns it
Sourcepub fn to_unconfined(&self) -> Cwhere
C: Clone,
pub fn to_unconfined(&self) -> Cwhere
C: Clone,
Clones inner collection and returns an unconfined version of it.
Sourcepub fn push(&mut self, elem: <C as Collection>::Item) -> Result<(), Error>
pub fn push(&mut self, elem: <C as Collection>::Item) -> Result<(), Error>
Attempts to add a single element to the confined collection. Fails if the number of elements in the collection already maximal.
Sourcepub fn extend<T>(&mut self, iter: T) -> Result<(), Error>
pub fn extend<T>(&mut self, iter: T) -> Result<(), Error>
Attempts to add all elements from an iterator to the confined collection. Fails if the number of elements in the collection already maximal.
Sourcepub fn len_u8(&self) -> u8
pub fn len_u8(&self) -> u8
Returns number of elements in the confined collection as u8
. The
confinement guarantees that the collection length can’t exceed
u8::MAX
.
Sourcepub fn len_u16(&self) -> u16
pub fn len_u16(&self) -> u16
Returns number of elements in the confined collection as u16
. The
confinement guarantees that the collection length can’t exceed
u16::MAX
.
Sourcepub fn len_u24(&self) -> u24
pub fn len_u24(&self) -> u24
Returns number of elements in the confined collection as u24
. The
confinement guarantees that the collection length can’t exceed
u24::MAX
.
Sourcepub fn len_u32(&self) -> u32
pub fn len_u32(&self) -> u32
Returns number of elements in the confined collection as u32
. The
confinement guarantees that the collection length can’t exceed
u32::MAX
.
Sourcepub fn get_mut(
&mut self,
key: &<C as KeyedCollection>::Key,
) -> Option<&mut <C as KeyedCollection>::Value>
pub fn get_mut( &mut self, key: &<C as KeyedCollection>::Key, ) -> Option<&mut <C as KeyedCollection>::Value>
Gets mutable reference to an element of the collection.
Sourcepub fn insert(
&mut self,
key: <C as KeyedCollection>::Key,
value: <C as KeyedCollection>::Value,
) -> Result<Option<<C as KeyedCollection>::Value>, Error>
pub fn insert( &mut self, key: <C as KeyedCollection>::Key, value: <C as KeyedCollection>::Value, ) -> Result<Option<<C as KeyedCollection>::Value>, Error>
Inserts a new value into the confined collection under a given key. Fails if the collection already contains maximum number of elements allowed by the confinement.
Sourcepub fn entry(
&mut self,
key: <C as KeyedCollection>::Key,
) -> Result<<C as KeyedCollection>::Entry<'_>, Error>
pub fn entry( &mut self, key: <C as KeyedCollection>::Key, ) -> Result<<C as KeyedCollection>::Entry<'_>, Error>
Gets the given key’s corresponding entry in the map for in-place manipulation. Errors if the collection entry is vacant and the collection has already reached maximal size of its confinement.
Sourcepub fn pop(&mut self) -> Option<char>
pub fn pop(&mut self) -> Option<char>
Removes the last character from a string and returns it, or None
if
it is empty.
Sourcepub fn remove(&mut self, index: usize) -> Result<char, Error>
pub fn remove(&mut self, index: usize) -> Result<char, Error>
Removes a single character from the confined string, unless the string doesn’t shorten more than the confinement requirement. Errors otherwise.
Sourcepub fn pop(&mut self) -> Option<AsciiChar>
pub fn pop(&mut self) -> Option<AsciiChar>
Removes the last character from a string and returns it, or None
if
it is empty.
Sourcepub fn remove(&mut self, index: usize) -> Result<AsciiChar, Error>
pub fn remove(&mut self, index: usize) -> Result<AsciiChar, Error>
Removes a single character from the confined string, unless the string doesn’t shorten more than the confinement requirement. Errors otherwise.
Sourcepub fn get_mut<I>(
&mut self,
index: I,
) -> Option<&mut <I as SliceIndex<[T]>>::Output>where
I: SliceIndex<[T]>,
pub fn get_mut<I>(
&mut self,
index: I,
) -> Option<&mut <I as SliceIndex<[T]>>::Output>where
I: SliceIndex<[T]>,
Gets the mutable element of a vector
Sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Removes the last element from a vector and returns it, or None
if it
is empty.
Sourcepub fn remove(&mut self, index: usize) -> Result<T, Error>
pub fn remove(&mut self, index: usize) -> Result<T, Error>
Removes an element from the vector at a given index. Errors if the index exceeds the number of elements in the vector, of if the new vector length will be less than the confinement requirement. Returns the removed element otherwise.
Sourcepub fn iter(&self) -> Iter<'_, T>
pub fn iter(&self) -> Iter<'_, T>
Returns an iterator over the slice.
The iterator yields all items from start to end.
Sourcepub fn pop_front(&mut self) -> Option<T>
pub fn pop_front(&mut self) -> Option<T>
Removes the first element and returns it, or None
if the deque is
empty.
Sourcepub fn pop_back(&mut self) -> Option<T>
pub fn pop_back(&mut self) -> Option<T>
Removes the last element and returns it, or None
if the deque is
empty.
Sourcepub fn push_front(&mut self, elem: T) -> Result<(), Error>
pub fn push_front(&mut self, elem: T) -> Result<(), Error>
Prepends an element to the deque. Errors if the new collection length will not fit the confinement requirements.
pub fn push_from(&mut self, elem: T) -> Result<(), Error>
push_front
Sourcepub fn push_back(&mut self, elem: T) -> Result<(), Error>
pub fn push_back(&mut self, elem: T) -> Result<(), Error>
Appends an element to the deque. Errors if the new collection length will not fit the confinement requirements.
Sourcepub fn remove(&mut self, index: usize) -> Result<T, Error>
pub fn remove(&mut self, index: usize) -> Result<T, Error>
Removes an element from the deque at a given index. Errors if the index exceeds the number of elements in the deque, of if the new deque length will be less than the confinement requirement. Returns the removed element otherwise.
Sourcepub fn drain<R>(&mut self, range: R) -> Drain<'_, T>where
R: RangeBounds<usize>,
pub fn drain<R>(&mut self, range: R) -> Drain<'_, T>where
R: RangeBounds<usize>,
Removes the specified range from the deque in bulk, returning all removed elements as an iterator. If the iterator is dropped before being fully consumed, it drops the remaining removed elements.
The returned iterator keeps a mutable borrow on the queue to optimize its implementation.
§Panics
Panics if the starting point is greater than the end point or if the end point is greater than the length of the deque.
§Leaking
If the returned iterator goes out of scope without being dropped (due to
[mem::forget
], for example), the deque may have lost and leaked
elements arbitrarily, including elements outside the range.
Sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Shortens the deque, keeping the first len
elements and dropping
the rest.
If len
is greater or equal to the deque’s current length, this has
no effect.
Sourcepub fn remove(&mut self, elem: &T) -> Result<bool, Error>
pub fn remove(&mut self, elem: &T) -> Result<bool, Error>
Removes an element from the set. Errors if the index exceeds the number of elements in the set, of if the new collection length will be less than the confinement requirement. Returns if the element was present in the set.
Sourcepub fn take(&mut self, elem: &T) -> Result<Option<T>, Error>
pub fn take(&mut self, elem: &T) -> Result<Option<T>, Error>
Removes an element from the set. Errors if the index exceeds the number of elements in the set, of if the new collection length will be less than the confinement requirement. Returns the removed element otherwise.
Sourcepub fn remove(&mut self, elem: &T) -> Result<bool, Error>
pub fn remove(&mut self, elem: &T) -> Result<bool, Error>
Removes an element from the set. Errors if the index exceeds the number of elements in the set, of if the new collection length will be less than the confinement requirement. Returns if the element was present in the set.
Sourcepub fn take(&mut self, elem: &T) -> Result<Option<T>, Error>
pub fn take(&mut self, elem: &T) -> Result<Option<T>, Error>
Removes an element from the set. Errors if the index exceeds the number of elements in the set, of if the new collection length will be less than the confinement requirement. Returns the removed element otherwise.
Trait Implementations§
Source§impl AsMut<<ScriptBytes as Wrapper>::Inner> for ScriptBytes
impl AsMut<<ScriptBytes as Wrapper>::Inner> for ScriptBytes
Source§impl AsMut<[u8]> for ScriptBytes
impl AsMut<[u8]> for ScriptBytes
Source§impl AsRef<[u8]> for ScriptBytes
impl AsRef<[u8]> for ScriptBytes
Source§impl AsRef<ScriptBytes> for RedeemScript
impl AsRef<ScriptBytes> for RedeemScript
Source§fn as_ref(&self) -> &ScriptBytes
fn as_ref(&self) -> &ScriptBytes
Source§impl AsRef<ScriptBytes> for ScriptCode
impl AsRef<ScriptBytes> for ScriptCode
Source§fn as_ref(&self) -> &ScriptBytes
fn as_ref(&self) -> &ScriptBytes
Source§impl AsRef<ScriptBytes> for ScriptPubkey
impl AsRef<ScriptBytes> for ScriptPubkey
Source§fn as_ref(&self) -> &ScriptBytes
fn as_ref(&self) -> &ScriptBytes
Source§impl AsRef<ScriptBytes> for SigScript
impl AsRef<ScriptBytes> for SigScript
Source§fn as_ref(&self) -> &ScriptBytes
fn as_ref(&self) -> &ScriptBytes
Source§impl AsRef<ScriptBytes> for TapScript
impl AsRef<ScriptBytes> for TapScript
Source§fn as_ref(&self) -> &ScriptBytes
fn as_ref(&self) -> &ScriptBytes
Source§impl AsRef<ScriptBytes> for WitnessScript
impl AsRef<ScriptBytes> for WitnessScript
Source§fn as_ref(&self) -> &ScriptBytes
fn as_ref(&self) -> &ScriptBytes
Source§impl Borrow<ScriptBytes> for RedeemScript
impl Borrow<ScriptBytes> for RedeemScript
Source§fn borrow(&self) -> &ScriptBytes
fn borrow(&self) -> &ScriptBytes
Source§impl Borrow<ScriptBytes> for ScriptCode
impl Borrow<ScriptBytes> for ScriptCode
Source§fn borrow(&self) -> &ScriptBytes
fn borrow(&self) -> &ScriptBytes
Source§impl Borrow<ScriptBytes> for ScriptPubkey
impl Borrow<ScriptBytes> for ScriptPubkey
Source§fn borrow(&self) -> &ScriptBytes
fn borrow(&self) -> &ScriptBytes
Source§impl Borrow<ScriptBytes> for SigScript
impl Borrow<ScriptBytes> for SigScript
Source§fn borrow(&self) -> &ScriptBytes
fn borrow(&self) -> &ScriptBytes
Source§impl Borrow<ScriptBytes> for TapScript
impl Borrow<ScriptBytes> for TapScript
Source§fn borrow(&self) -> &ScriptBytes
fn borrow(&self) -> &ScriptBytes
Source§impl Borrow<ScriptBytes> for WitnessScript
impl Borrow<ScriptBytes> for WitnessScript
Source§fn borrow(&self) -> &ScriptBytes
fn borrow(&self) -> &ScriptBytes
Source§impl BorrowMut<<ScriptBytes as Wrapper>::Inner> for ScriptBytes
impl BorrowMut<<ScriptBytes as Wrapper>::Inner> for ScriptBytes
Source§fn borrow_mut(&mut self) -> &mut <ScriptBytes as Wrapper>::Inner
fn borrow_mut(&mut self) -> &mut <ScriptBytes as Wrapper>::Inner
Source§impl Clone for ScriptBytes
impl Clone for ScriptBytes
Source§fn clone(&self) -> ScriptBytes
fn clone(&self) -> ScriptBytes
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl ConsensusDecode for ScriptBytes
impl ConsensusDecode for ScriptBytes
fn consensus_decode( reader: &mut impl Read, ) -> Result<ScriptBytes, ConsensusDecodeError>
fn consensus_deserialize( bytes: impl AsRef<[u8]>, ) -> Result<Self, ConsensusDecodeError>
Source§impl ConsensusEncode for ScriptBytes
impl ConsensusEncode for ScriptBytes
Source§impl Debug for ScriptBytes
impl Debug for ScriptBytes
Source§impl Default for ScriptBytes
impl Default for ScriptBytes
Source§fn default() -> ScriptBytes
fn default() -> ScriptBytes
Source§impl Deref for ScriptBytes
impl Deref for ScriptBytes
Source§impl DerefMut for ScriptBytes
impl DerefMut for ScriptBytes
Source§impl From<RedeemScript> for ScriptBytes
impl From<RedeemScript> for ScriptBytes
Source§fn from(wrapped: RedeemScript) -> ScriptBytes
fn from(wrapped: RedeemScript) -> ScriptBytes
Source§impl From<ScriptBytes> for RedeemScript
impl From<ScriptBytes> for RedeemScript
Source§fn from(v: ScriptBytes) -> RedeemScript
fn from(v: ScriptBytes) -> RedeemScript
Source§impl From<ScriptBytes> for ScriptCode
impl From<ScriptBytes> for ScriptCode
Source§fn from(v: ScriptBytes) -> ScriptCode
fn from(v: ScriptBytes) -> ScriptCode
Source§impl From<ScriptBytes> for ScriptPubkey
impl From<ScriptBytes> for ScriptPubkey
Source§fn from(v: ScriptBytes) -> ScriptPubkey
fn from(v: ScriptBytes) -> ScriptPubkey
Source§impl From<ScriptBytes> for SigScript
impl From<ScriptBytes> for SigScript
Source§fn from(v: ScriptBytes) -> SigScript
fn from(v: ScriptBytes) -> SigScript
Source§impl From<ScriptBytes> for TapScript
impl From<ScriptBytes> for TapScript
Source§fn from(v: ScriptBytes) -> TapScript
fn from(v: ScriptBytes) -> TapScript
Source§impl From<ScriptBytes> for WitnessScript
impl From<ScriptBytes> for WitnessScript
Source§fn from(v: ScriptBytes) -> WitnessScript
fn from(v: ScriptBytes) -> WitnessScript
Source§impl From<ScriptCode> for ScriptBytes
impl From<ScriptCode> for ScriptBytes
Source§fn from(wrapped: ScriptCode) -> ScriptBytes
fn from(wrapped: ScriptCode) -> ScriptBytes
Source§impl From<ScriptPubkey> for ScriptBytes
impl From<ScriptPubkey> for ScriptBytes
Source§fn from(wrapped: ScriptPubkey) -> ScriptBytes
fn from(wrapped: ScriptPubkey) -> ScriptBytes
Source§impl From<SigScript> for ScriptBytes
impl From<SigScript> for ScriptBytes
Source§fn from(wrapped: SigScript) -> ScriptBytes
fn from(wrapped: SigScript) -> ScriptBytes
Source§impl From<TapScript> for ScriptBytes
impl From<TapScript> for ScriptBytes
Source§fn from(wrapped: TapScript) -> ScriptBytes
fn from(wrapped: TapScript) -> ScriptBytes
Source§impl From<WitnessScript> for ScriptBytes
impl From<WitnessScript> for ScriptBytes
Source§fn from(wrapped: WitnessScript) -> ScriptBytes
fn from(wrapped: WitnessScript) -> ScriptBytes
Source§impl FromHex for ScriptBytes
impl FromHex for ScriptBytes
Source§fn from_byte_iter<I>(iter: I) -> Result<ScriptBytes, Error>
fn from_byte_iter<I>(iter: I) -> Result<ScriptBytes, Error>
Source§impl Hash for ScriptBytes
impl Hash for ScriptBytes
Source§impl LowerHex for ScriptBytes
impl LowerHex for ScriptBytes
Source§impl Ord for ScriptBytes
impl Ord for ScriptBytes
Source§fn cmp(&self, other: &ScriptBytes) -> Ordering
fn cmp(&self, other: &ScriptBytes) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ScriptBytes
impl PartialEq for ScriptBytes
Source§impl PartialOrd for ScriptBytes
impl PartialOrd for ScriptBytes
Source§impl StrictDecode for ScriptBytes
impl StrictDecode for ScriptBytes
fn strict_decode( reader: &mut impl TypedRead, ) -> Result<ScriptBytes, DecodeError>
fn strict_read(reader: impl ReadRaw) -> Result<Self, DecodeError>
Source§impl StrictEncode for ScriptBytes
impl StrictEncode for ScriptBytes
fn strict_encode<W>(&self, writer: W) -> Result<W, Error>where
W: TypedWrite,
fn strict_write(&self, writer: impl WriteRaw) -> Result<(), Error>
Source§impl StrictTuple for ScriptBytes
impl StrictTuple for ScriptBytes
const FIELD_COUNT: u8 = 1u8
fn strict_check_fields()
fn strict_type_info() -> TypeInfo<Self>
Source§impl StrictType for ScriptBytes
impl StrictType for ScriptBytes
const STRICT_LIB_NAME: &'static str = LIB_NAME_BITCOIN
fn strict_name() -> Option<TypeName>
Source§impl UpperHex for ScriptBytes
impl UpperHex for ScriptBytes
Source§impl Wrapper for ScriptBytes
impl Wrapper for ScriptBytes
Source§type Inner = Confined<Vec<u8>, 0, bc::::coding::VarIntBytes::{constant#1}>
type Inner = Confined<Vec<u8>, 0, bc::::coding::VarIntBytes::{constant#1}>
Source§fn from_inner(inner: <ScriptBytes as Wrapper>::Inner) -> ScriptBytes
fn from_inner(inner: <ScriptBytes as Wrapper>::Inner) -> ScriptBytes
Source§fn as_inner(&self) -> &<ScriptBytes as Wrapper>::Inner
fn as_inner(&self) -> &<ScriptBytes as Wrapper>::Inner
Source§fn into_inner(self) -> <ScriptBytes as Wrapper>::Inner
fn into_inner(self) -> <ScriptBytes as Wrapper>::Inner
Source§impl WrapperMut for ScriptBytes
impl WrapperMut for ScriptBytes
Source§fn as_inner_mut(&mut self) -> &mut <ScriptBytes as Wrapper>::Inner
fn as_inner_mut(&mut self) -> &mut <ScriptBytes as Wrapper>::Inner
impl Eq for ScriptBytes
impl StrictProduct for ScriptBytes
impl StructuralPartialEq for ScriptBytes
Auto Trait Implementations§
impl Freeze for ScriptBytes
impl RefUnwindSafe for ScriptBytes
impl Send for ScriptBytes
impl Sync for ScriptBytes
impl Unpin for ScriptBytes
impl UnwindSafe for ScriptBytes
Blanket Implementations§
Source§impl<T> Base32Len for T
impl<T> Base32Len for T
Source§fn base32_len(&self) -> usize
fn base32_len(&self) -> usize
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> CheckBase32<Vec<u5>> for T
impl<T> CheckBase32<Vec<u5>> for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.