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
impl BlueprintCodec
Sourcepub fn encode_writer<W, F>(writer: W, inner: F) -> Result<()>where
W: Write,
F: FnOnce(ZlibEncoder<&mut Base64Encoder<'_, VersionPrefixWriter<W>>>) -> Result<()>,
pub fn encode_writer<W, F>(writer: W, inner: F) -> Result<()>where
W: Write,
F: FnOnce(ZlibEncoder<&mut Base64Encoder<'_, VersionPrefixWriter<W>>>) -> 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.
Sourcepub fn encode<W: Write>(writer: W, container: &Container) -> Result<()>
pub fn encode<W: Write>(writer: W, container: &Container) -> Result<()>
write the blueprint string to the given writer
Sourcepub fn encode_string(container: &Container) -> Result<String>
pub fn encode_string(container: &Container) -> Result<String>
produce a new owned string containing the blueprint string
Sourcepub fn decode_reader<R, F>(reader: R, inner: F) -> Result<()>where
R: Read,
F: FnOnce(ZlibDecoder<Base64Decoder<'_, VersionPrefixReader<WhitespaceRemover<R>>>>) -> Result<()>,
pub fn decode_reader<R, F>(reader: R, inner: F) -> Result<()>where
R: Read,
F: FnOnce(ZlibDecoder<Base64Decoder<'_, VersionPrefixReader<WhitespaceRemover<R>>>>) -> 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
Sourcepub fn decode<R: Read>(reader: R) -> Result<Container>
pub fn decode<R: Read>(reader: R) -> Result<Container>
read the blueprint string from the given reader
Sourcepub fn decode_string(blueprint: &str) -> Result<Container>
pub fn decode_string(blueprint: &str) -> Result<Container>
read the blueprint string from the given input
Auto Trait Implementations§
impl Freeze for BlueprintCodec
impl RefUnwindSafe for BlueprintCodec
impl Send for BlueprintCodec
impl Sync for BlueprintCodec
impl Unpin for BlueprintCodec
impl UnwindSafe for BlueprintCodec
Blanket Implementations§
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
Mutably borrows from an owned value. Read more