"corona" is already taken - renaming

This commit is contained in:
Cerber Ursi
2021-11-27 19:09:16 +07:00
parent a7aef1657d
commit 67a1a6203f
8 changed files with 40 additions and 108 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
[package]
name = "corona"
name = "uneval"
version = "0.1.0"
authors = ["k.bagrov <k.bagrov@g.nsu.ru>"]
edition = "2018"
+1 -3
View File
@@ -1,6 +1,4 @@
# corona
![CoRONa - Compile-time Rust Objects, Native](rust-logo-blk.svg)
# uneval
Makes [Serde](http://serde.rs) serialize your data to the Rust source code.
-66
View File
@@ -1,66 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg>
<defs
id="defs12">
<linearGradient
id="linearGradient827-3">
<stop
style="stop-color:#000000;stop-opacity:0"
offset="0"
id="stop823" />
<stop
id="stop838"
offset="0.5529865"
style="stop-color:#fffba3;stop-opacity:0" />
<stop
style="stop-color:#fffba4;stop-opacity:0.72375691"
offset="0.61849707"
id="stop840" />
<stop
id="stop842"
offset="0.73410404"
style="stop-color:#fff746;stop-opacity:0.97237569" />
<stop
style="stop-color:#fff522;stop-opacity:0.97237569"
offset="0.87668586"
id="stop846" />
<stop
style="stop-color:#fff401;stop-opacity:0.77348065"
offset="0.94604999"
id="stop844" />
<stop
style="stop-color:#fff400;stop-opacity:0"
offset="1"
id="stop825" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient827-3"
id="radialGradient831"
cx="71.837257"
cy="70.976242"
fx="71.837257"
fy="70.976242"
r="57.599239"
gradientTransform="matrix(1,0,0,0.97191015,0,1.9937123)"
gradientUnits="userSpaceOnUse" />
</defs>
<path
d="m71.05 23.68c-26.06 0-47.27 21.22-47.27 47.27s21.22 47.27 47.27 47.27 47.27-21.22 47.27-47.27-21.22-47.27-47.27-47.27zm-.07 4.2a3.1 3.11 0 0 1 3.02 3.11 3.11 3.11 0 0 1 -6.22 0 3.11 3.11 0 0 1 3.2-3.11zm7.12 5.12a38.27 38.27 0 0 1 26.2 18.66l-3.67 8.28c-.63 1.43.02 3.11 1.44 3.75l7.06 3.13a38.27 38.27 0 0 1 .08 6.64h-3.93c-.39 0-.55.26-.55.64v1.8c0 4.24-2.39 5.17-4.49 5.4-2 .23-4.21-.84-4.49-2.06-1.18-6.63-3.14-8.04-6.24-10.49 3.85-2.44 7.85-6.05 7.85-10.87 0-5.21-3.57-8.49-6-10.1-3.42-2.25-7.2-2.7-8.22-2.7h-40.6a38.27 38.27 0 0 1 21.41-12.08l4.79 5.02c1.08 1.13 2.87 1.18 4 .09zm-44.2 23.02a3.11 3.11 0 0 1 3.02 3.11 3.11 3.11 0 0 1 -6.22 0 3.11 3.11 0 0 1 3.2-3.11zm74.15.14a3.11 3.11 0 0 1 3.02 3.11 3.11 3.11 0 0 1 -6.22 0 3.11 3.11 0 0 1 3.2-3.11zm-68.29.5h5.42v24.44h-10.94a38.27 38.27 0 0 1 -1.24-14.61l6.7-2.98c1.43-.64 2.08-2.31 1.44-3.74zm22.62.26h12.91c.67 0 4.71.77 4.71 3.8 0 2.51-3.1 3.41-5.65 3.41h-11.98zm0 17.56h9.89c.9 0 4.83.26 6.08 5.28.39 1.54 1.26 6.56 1.85 8.17.59 1.8 2.98 5.4 5.53 5.4h16.14a38.27 38.27 0 0 1 -3.54 4.1l-6.57-1.41c-1.53-.33-3.04.65-3.37 2.18l-1.56 7.28a38.27 38.27 0 0 1 -31.91-.15l-1.56-7.28c-.33-1.53-1.83-2.51-3.36-2.18l-6.43 1.38a38.27 38.27 0 0 1 -3.32-3.92h31.27c.35 0 .59-.06.59-.39v-11.06c0-.32-.24-.39-.59-.39h-9.15zm-14.43 25.33a3.11 3.11 0 0 1 3.02 3.11 3.11 3.11 0 0 1 -6.22 0 3.11 3.11 0 0 1 3.2-3.11zm46.05.14a3.11 3.11 0 0 1 3.02 3.11 3.11 3.11 0 0 1 -6.22 0 3.11 3.11 0 0 1 3.2-3.11z"
id="path2" />
<path
d="m115.68 70.95a44.63 44.63 0 0 1 -44.63 44.63 44.63 44.63 0 0 1 -44.63-44.63 44.63 44.63 0 0 1 44.63-44.63 44.63 44.63 0 0 1 44.63 44.63zm-.84-4.31 6.96 4.31-6.96 4.31 5.98 5.59-7.66 2.87 4.78 6.65-8.09 1.32 3.4 7.46-8.19-.29 1.88 7.98-7.98-1.88.29 8.19-7.46-3.4-1.32 8.09-6.65-4.78-2.87 7.66-5.59-5.98-4.31 6.96-4.31-6.96-5.59 5.98-2.87-7.66-6.65 4.78-1.32-8.09-7.46 3.4.29-8.19-7.98 1.88 1.88-7.98-8.19.29 3.4-7.46-8.09-1.32 4.78-6.65-7.66-2.87 5.98-5.59-6.96-4.31 6.96-4.31-5.98-5.59 7.66-2.87-4.78-6.65 8.09-1.32-3.4-7.46 8.19.29-1.88-7.98 7.98 1.88-.29-8.19 7.46 3.4 1.32-8.09 6.65 4.78 2.87-7.66 5.59 5.98 4.31-6.96 4.31 6.96 5.59-5.98 2.87 7.66 6.65-4.78 1.32 8.09 7.46-3.4-.29 8.19 7.98-1.88-1.88 7.98 8.19-.29-3.4 7.46 8.09 1.32-4.78 6.65 7.66 2.87z"
fill-rule="evenodd"
stroke="#000"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="3"
id="path4" />
<ellipse
id="path16"
cx="71.05"
cy="71.05"
rx="60"
ry="60"
style="fill-opacity:1;fill:url(#radialGradient831)" />
</svg>

Before

Width:  |  Height:  |  Size: 3.8 KiB

+3 -3
View File
@@ -1,10 +1,10 @@
//! Error returned by Corona serializer.
//! Error returned by Uneval serializer.
use serde::ser;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum CoronaError {
pub enum UnevalError {
#[error("IO error while writing code: {0}")]
Io(#[from] std::io::Error),
#[error("Serialization process yielded invalid UTF-8 sequence: {0}")]
@@ -13,7 +13,7 @@ pub enum CoronaError {
Custom(String),
}
impl ser::Error for CoronaError {
impl ser::Error for UnevalError {
fn custom<T>(msg:T)->Self where T: std::fmt::Display {
Self::Custom(msg.to_string())
}
+10 -10
View File
@@ -1,17 +1,17 @@
//! Convenience functions to be used with Corona.
//! Convenience functions to be used with Uneval.
use crate::ser::{SerResult, Corona};
use crate::error::CoronaError;
use crate::ser::{SerResult, Uneval};
use crate::error::UnevalError;
use serde::Serialize;
/// Write generated Rust code to the provided [`Write`][std::io::Write] implementation.
pub fn write(value: impl Serialize, target: impl std::io::Write) -> SerResult {
value.serialize(&mut Corona::new(target))
value.serialize(&mut Uneval::new(target))
}
/// Writes generated Rust code to file.
///
/// This is probably the most common way to use `corona`. When Cargo runs your crate's build task,
/// This is probably the most common way to use `uneval`. When Cargo runs your crate's build task,
/// it sets the `OUT_DIR` environment variable to the path to build target directory (see
/// [Cargo reference](https://doc.rust-lang.org/cargo/reference/environment-variables.html) for more).
/// So, you can use it in two steps:
@@ -22,7 +22,7 @@ pub fn write(value: impl Serialize, target: impl std::io::Write) -> SerResult {
/// std::env::var("OUT_DIR").expect("No build target path set"),
/// "file_name.rs".into()
/// ].iter().collect();
/// corona::to_file(value, path).expect("Write failed");
/// uneval::to_file(value, path).expect("Write failed");
/// ```
/// 2. [Include][include] the generated Rust code wherever it is needed:
/// ```ignore
@@ -31,7 +31,7 @@ pub fn write(value: impl Serialize, target: impl std::io::Write) -> SerResult {
///
/// [include]: https://doc.rust-lang.org/stable/std/macro.include.html
pub fn to_file(value: impl Serialize, target: impl AsRef<std::path::Path>) -> SerResult {
value.serialize(&mut Corona::new(std::fs::File::create(target)?))
value.serialize(&mut Uneval::new(std::fs::File::create(target)?))
}
/// Convenience wrapper around [`to_file`].
@@ -43,12 +43,12 @@ pub fn to_out_dir(value: impl Serialize, file_name: impl AsRef<str>) -> SerResul
std::env::var("OUT_DIR").expect("OUT_DIR not set, check if you're running this from the build script"),
file_name.as_ref().into()
].iter().collect();
value.serialize(&mut Corona::new(std::fs::File::create(path)?))
value.serialize(&mut Uneval::new(std::fs::File::create(path)?))
}
/// Obtain string with generated Rust code.
pub fn to_string(value: impl Serialize) -> Result<String, CoronaError> {
pub fn to_string(value: impl Serialize) -> Result<String, UnevalError> {
let mut out = Vec::new();
value.serialize(&mut Corona::new(&mut out))?;
value.serialize(&mut Uneval::new(&mut out))?;
Ok(String::from_utf8(out)?)
}
+3 -3
View File
@@ -9,21 +9,21 @@
//! ## Usage
//! In general, to embed some code into crate, you have to use the build script
//! and [`include!`][include] macro. Inside the build script, you'll generate
//! some code with one of the [functions][funcs] provided by `corona`,
//! some code with one of the [functions][funcs] provided by `uneval`,
//! and then include the generated file, like this:
//! ```ignore
//! let value = include!(concat!(env!(OUT_DIR), "/file_name.rs"));
//! ```
//!
//! ## Limitations
//! There are some cases when `corona` will be unable to generate valid code. Namely:
//! There are some cases when `uneval` will be unable to generate valid code. Namely:
//! 1. Since Serde doesn't provide us the full path to the type in question (and in most cases it's simply unable to),
//! all the structs and enums used during value construction must be in scope.
//! As a consequence, all of them must have distinct names - otherwise, there will be name clashes.
//! 2. This serializer is intended for use with derived implementation. It may return bogus results
//! when used with customized `Serialize`.
//! 3. It is impossible to consume code for the type with private fields outside from the module it is defined in.
//! In fact, to be able to use this type with `corona`, you'll have to distribute two copies of your crate,
//! In fact, to be able to use this type with `uneval`, you'll have to distribute two copies of your crate,
//! one of which would only export the definition with derived `Serialize` to be used by serializer
//! during the build-time of the second copy. (Isn't this a bit too complex?)
//! 4. It is impossible to use empty tuple structs (i.e. `Empty()`).
+21 -21
View File
@@ -1,21 +1,21 @@
//! Implementation of the Corona serializer.
//! Implementation of the Uneval serializer.
use crate::error::CoronaError;
use crate::error::UnevalError;
use serde::ser;
use std::io::Write;
pub(crate) type SerResult = Result<(), CoronaError>;
pub(crate) type SerResult = Result<(), UnevalError>;
/// Main serializer implementation.
///
/// Users are usually encouraged to use [`to_out_dir`][crate::funcs::to_out_dir] or, in special cases,
/// [`to_file`][crate::funcs::to_file], [`write`][crate::funcs::write] or [`to_string`][crate::funcs::to_string].
pub struct Corona<W: Write> {
pub struct Uneval<W: Write> {
writer: W,
inside: bool,
}
impl<W: Write> Corona<W> {
impl<W: Write> Uneval<W> {
pub(crate) fn new(target: W) -> Self {
Self {
writer: target,
@@ -43,9 +43,9 @@ impl<W: Write> Corona<W> {
}
}
impl<W: Write> ser::Serializer for &mut Corona<W> {
impl<W: Write> ser::Serializer for &mut Uneval<W> {
type Ok = ();
type Error = CoronaError;
type Error = UnevalError;
type SerializeSeq = Self;
type SerializeTuple = Self;
@@ -252,9 +252,9 @@ impl<W: Write> ser::Serializer for &mut Corona<W> {
}
}
impl<W: Write> ser::SerializeSeq for &mut Corona<W> {
impl<W: Write> ser::SerializeSeq for &mut Uneval<W> {
type Ok = ();
type Error = CoronaError;
type Error = UnevalError;
fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
where
@@ -268,9 +268,9 @@ impl<W: Write> ser::SerializeSeq for &mut Corona<W> {
Ok(())
}
}
impl<W: Write> ser::SerializeTuple for &mut Corona<W> {
impl<W: Write> ser::SerializeTuple for &mut Uneval<W> {
type Ok = ();
type Error = CoronaError;
type Error = UnevalError;
fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
where
@@ -284,9 +284,9 @@ impl<W: Write> ser::SerializeTuple for &mut Corona<W> {
Ok(())
}
}
impl<W: Write> ser::SerializeTupleStruct for &mut Corona<W> {
impl<W: Write> ser::SerializeTupleStruct for &mut Uneval<W> {
type Ok = ();
type Error = CoronaError;
type Error = UnevalError;
fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
where
@@ -300,9 +300,9 @@ impl<W: Write> ser::SerializeTupleStruct for &mut Corona<W> {
Ok(())
}
}
impl<W: Write> ser::SerializeTupleVariant for &mut Corona<W> {
impl<W: Write> ser::SerializeTupleVariant for &mut Uneval<W> {
type Ok = ();
type Error = CoronaError;
type Error = UnevalError;
fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
where
@@ -316,9 +316,9 @@ impl<W: Write> ser::SerializeTupleVariant for &mut Corona<W> {
Ok(())
}
}
impl<W: Write> ser::SerializeMap for &mut Corona<W> {
impl<W: Write> ser::SerializeMap for &mut Uneval<W> {
type Ok = ();
type Error = CoronaError;
type Error = UnevalError;
fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), Self::Error>
where
@@ -345,9 +345,9 @@ impl<W: Write> ser::SerializeMap for &mut Corona<W> {
Ok(())
}
}
impl<W: Write> ser::SerializeStruct for &mut Corona<W> {
impl<W: Write> ser::SerializeStruct for &mut Uneval<W> {
type Ok = ();
type Error = CoronaError;
type Error = UnevalError;
fn serialize_field<T: ?Sized>(
&mut self,
@@ -368,9 +368,9 @@ impl<W: Write> ser::SerializeStruct for &mut Corona<W> {
Ok(())
}
}
impl<W: Write> ser::SerializeStructVariant for &mut Corona<W> {
impl<W: Write> ser::SerializeStructVariant for &mut Uneval<W> {
type Ok = ();
type Error = CoronaError;
type Error = UnevalError;
fn serialize_field<T: ?Sized>(
&mut self,
+1 -1
View File
@@ -1,4 +1,4 @@
use corona::to_file;
use uneval::to_file;
use batch_run::{{Batch, config::Config}};
mod definition;