Struct BlueprintCodec

Source
pub struct BlueprintCodec;
Expand description

Utility class which knows how to convert JSON to and from Factorio’s blueprint string format.

Implementations§

Source§

impl BlueprintCodec

Source

pub fn encode_writer<W, F>(writer: W, inner: F) -> Result<()>

writer adaptor which encodes json data to blueprint string format

typically it is more useful to use encode instead, but this method provides some extra flexibility.

Source

pub fn encode<W: Write>(writer: W, container: &Container) -> Result<()>

write the blueprint string to the given writer

Source

pub fn encode_string(container: &Container) -> Result<String>

produce a new owned string containing the blueprint string

Source

pub fn decode_reader<R, F>(reader: R, inner: F) -> Result<()>

reader adaptor which decodes a blueprint string to json

typically it is more useful to use decode instead, but this method gives flexibility in the event that it is required

Source

pub fn decode<R: Read>(reader: R) -> Result<Container>

read the blueprint string from the given reader

Source

pub fn decode_string(blueprint: &str) -> Result<Container>

read the blueprint string from the given input

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.