SpudObjectSync

Struct SpudObjectSync 

Source
pub struct SpudObjectSync { /* private fields */ }
Expand description

Represents a SPUD object, which is a collection of fields and values. It allows adding values to fields and manages the internal data structure for SPUD encoding.

Implementations§

Source§

impl SpudObjectSync

Source

pub fn add_value<T: SpudTypesExt>( &self, field_name: &str, value: T, ) -> Result<&Self, SpudError>

Adds a value to the object with the specified field name.

§Arguments
  • field_name - The name of the field to which the value will be added.
  • value - The value to be added, which must implement the SpudTypesExt trait.
§Examples
use spud_rs::{SpudBuilder, SpudObjectSync, types::SpudString};

let builder = SpudBuilder::new();

builder.object(|obj| {
    obj.add_value("example_field", SpudString::from("example_value"));

    Ok(())
});

// The object now contains the field "example_field" with the value "example_value".
§Returns

A mutable reference to the SpudObjectSync, allowing for method chaining.

§Errors

If the field name is too long (greater than 255 characters) or if there is an error generating a unique ID, this method will return an error.

§Panics

Panics if the Mutex cannot be locked, which is unlikely but can happen in case of a deadlock or other synchronization issues.

Source

pub fn object<F>(&self, field_name: &str, f: F) -> Result<(), SpudError>

Creates a new SpudObjectSync instance associated with this Object.

§Errors

Returns an error if the object cannot be created, typically due to internal issues with the builder’s state.

§Panics

Panics if the Mutex cannot be locked, which is unlikely but can happen in case of a deadlock or other synchronization issues.

Trait Implementations§

Source§

impl Debug for SpudObjectSync

Source§

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

Formats the value using the given formatter. Read more

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> 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, 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.