commit 5534b4e1dbf90c767c8c7b1d30eadb695ac2faa9
Author: Zack Newman <zack@philomathiclife.com>
Date: Mon, 20 Mar 2023 16:14:07 -0600
initial
Diffstat:
6 files changed, 432 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,2 @@
+Cargo.lock
+target/**
diff --git a/Cargo.toml b/Cargo.toml
@@ -0,0 +1,15 @@
+[package]
+authors = ["Zack Newman <zack@philomathiclife.com>"]
+categories = ["command-line-utilities"]
+description = "Generates the code for the System.Data.IDataReader subtypes in the BulkWriters128 and BulkWriters256 C# shared libraries."
+edition = "2021"
+keywords = ["cli", "C#"]
+license = "MIT OR Apache-2.0"
+name = "gen_readers"
+readme = "README.md"
+repository = "https://git.philomathiclife.com/repos/gen_readers/"
+version = "1.0.0"
+
+[[bin]]
+name = "gr"
+path = "src/main.rs"
diff --git a/LICENSE-APACHE b/LICENSE-APACHE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/LICENSE-MIT b/LICENSE-MIT
@@ -0,0 +1,20 @@
+Copyright © 2023 Zack Newman
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+“Software”), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
@@ -0,0 +1,4 @@
+gen_readers
+--------
+Generates the code for the `System.Data.IDataReader` subtypes in the
+`BulkWriters128` and `BulkWriters256` C# shared libraries.
diff --git a/src/main.rs b/src/main.rs
@@ -0,0 +1,214 @@
+//! This crate generates the code for the `System.Data.IDataReader`
+//! subtypes in the `BulkWriters128` and `BulkWriters256` C# libraries.
+#![no_implicit_prelude]
+#![deny(
+ unsafe_code,
+ unused,
+ warnings,
+ clippy::all,
+ clippy::cargo,
+ clippy::nursery,
+ clippy::pedantic
+)]
+#![allow(
+ clippy::arithmetic_side_effects,
+ clippy::implicit_return,
+ clippy::integer_arithmetic
+)]
+#[allow(unused_extern_crates)]
+extern crate alloc;
+#[allow(unused_extern_crates)]
+extern crate core;
+#[allow(unused_extern_crates)]
+extern crate std;
+use alloc::string::{String, ToString};
+use core::clone::Clone;
+use core::convert::From;
+use core::fmt::{self, Debug, Display, Formatter};
+use core::result::Result::{self, Ok};
+use std::env;
+use std::fs::File;
+use std::io::{Error, Write};
+fn main() -> Result<(), GenErr> {
+ #[allow(deprecated)]
+ let mut path0 = env::home_dir().ok_or(GenErr::HomeVarNotSet)?;
+ path0.push(".c#");
+ let mut path1 = path0.clone();
+ path0.push("BulkWriters128/IterDataReaders.cs");
+ let mut f = File::options().write(true).create_new(true).open(path0)?;
+ path1.push("BulkWriters256/IterDataReaders.cs");
+ let mut f2 = File::options().write(true).create_new(true).open(path1)?;
+ let mut s = String::with_capacity(270_988);
+ write(&mut f, 0, &mut s)?;
+ write(&mut f2, 128, &mut s)?;
+ Ok(())
+}
+/// Writes the file.
+/// `s` is used as a buffer to write an entire `IterDataReader` into
+/// before being used by `f` to write to the underlying file descriptor.
+/// `v` is the starting arity of tuples: 0 or 128.
+fn write(f: &mut File, v: u8, s: &mut String) -> Result<(), Error> {
+ s.push_str("// This code was generated via a CLI app that used the source code in IterDataReaderBaseCase.cs as a template.
+// To improve compilation performance, the code uses very little 'whitespace' beyond what is necessary and contains no documentation, warning suppressions, or comments.
+using Serde.Bin.Ser;
+using static SQLServer.Helpers;
+using Std;
+using Std.Iter;
+using Std.Maybe;
+using Std.Vec;
+using System;
+using System.Data;
+using System.Data.SqlTypes;
+#pragma warning disable CA1502, CA1505, CS8618
+namespace SQLServer {\n");
+ for i in (if v == 0 { 1 } else { v })..=(v + 127) {
+ s.push_str("sealed class IterDataReader<TRowIter,TRow,TProd,TErr,");
+ for j in 0..=i {
+ Kind::T.write(s, j);
+ }
+ s.pop();
+ s.push_str(">:IDataReader ");
+ for j in 0..=i {
+ Kind::Bound.write(s, j);
+ }
+ s.push_str(
+ "where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<",
+ );
+ for j in 0..=i {
+ Kind::T.write(s, j);
+ }
+ s.pop();
+ s.push_str(r#">where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{internal IterDataReader(Maybe<ErrorTable>error,UserTable table,Prod<ulong,double>maxErrorsAllowed,ulong currentProcessed,ulong currentError,TRowIter iter,string processName,string userName,bool numericRoundAbort,string truncationStackTrace)=>(_error,_table,_errTableExists,_maxErrorsAllowed,CurrentProcessedCount,CurrentErrorCount,_iter,_errs,_isClosed,_numericRoundAbort,_current,_processName,_userName,_truncationStackTrace, _ser)=(error.IsSome?error.Unwrap():default,table,error.IsSome,maxErrorsAllowed,currentProcessed,currentError,iter,new Vec<Prod<nvarchar,nvarchar,varbinary>>(),false,numericRoundAbort,default!,processName,userName,new(truncationStackTrace),Serializer.New());readonly ErrorTable _error;readonly UserTable _table;TProd _current;Serializer _ser;readonly Prod<ulong,double>_maxErrorsAllowed;Vec<Prod<nvarchar,nvarchar,varbinary>>_errs;TRowIter _iter;readonly nvarchar _truncationStackTrace;readonly string _processName;readonly string _userName;internal ulong CurrentErrorCount;internal ulong CurrentProcessedCount;readonly bool _errTableExists;readonly bool _numericRoundAbort;bool _isClosed;public bool IsClosed=>_isClosed;double CurrentErrorRatio=>(double)CurrentErrorCount/CurrentProcessedCount;public int Depth=>0;public int FieldCount=>_table.ColumnCount;public object this[int ordinal]=>GetValue(ordinal);public object this[string columnName]=>GetValue(GetOrdinal(columnName));public int RecordsAffected=>-1;public void Close()=>Dispose();public void Dispose(){if(_isClosed){return;}(_isClosed,_current,_iter,_ser)=(true,default!,default!,default);if(_errTableExists){_=WriteErrors(in _error,ref _errs,_processName,_userName,ushort.MinValue);}_errs=new Vec<Prod<nvarchar,nvarchar,varbinary>>();}public sealed override bool Equals(object?_)=>false;public bool GetBoolean(int ordinal)=>(bool)GetValue(ordinal);public byte GetByte(int ordinal)=>(byte)GetValue(ordinal);public long GetBytes(int ordinal,long dataOffset,byte[]?buffer,int bufferOffset,int length){var val=GetValue(ordinal);var bytes=(byte[])val;var offset=(int)dataOffset;var len=bytes.Length-offset;if(len<=0){return 0L;}var count=Math.Min(len,length);var i=0;while(i<count){buffer![bufferOffset+i]=bytes[offset+i++];}return count;}public char GetChar(int ordinal){var val=(string)GetValue(ordinal);return val.Length==1?val[0]:throw new InvalidCastException();}public long GetChars(int ordinal,long dataOffset,char[]?buffer,int bufferOffset,int length){var val=GetValue(ordinal);var chars=(string)val;var offset=(int)dataOffset;var len=chars.Length-offset;if(len<=0){return 0L;}var count=Math.Min(len,length);var i=0;while(i<count){buffer![bufferOffset+i]=chars[offset+i++];}return count;}public IDataReader GetData(int _)=>throw new NotSupportedException();public string GetDataTypeName(int ordinal)=>GetFieldType(ordinal).Name;public DateTime GetDateTime(int ordinal){var type=GetFieldType(ordinal);return type==typeof(DateTime)?(DateTime)GetValue(ordinal):((SqlDateTime)GetValue(ordinal)).Value;}public decimal GetDecimal(int ordinal){var type=GetFieldType(ordinal);return type==typeof(SqlDecimal)?((SqlDecimal)GetValue(ordinal)).Value:((SqlMoney)GetValue(ordinal)).Value;}public double GetDouble(int ordinal)=>(double)GetValue(ordinal);public Type GetFieldType(int ordinal)=>_typeMap[_table[(ushort)ordinal].DataType];public float GetFloat(int ordinal)=>(float)GetValue(ordinal);public Guid GetGuid(int ordinal)=>(Guid)GetValue(ordinal);public sealed override int GetHashCode()=>0;public short GetInt16(int ordinal)=>(short)GetValue(ordinal);public int GetInt32(int ordinal)=>(int)GetValue(ordinal);public long GetInt64(int ordinal)=>(long)GetValue(ordinal);public string GetName(int ordinal)=>_table[(ushort)ordinal].Name;public int GetOrdinal(string name){for(ushort i=0;i<_table.ColumnCount;i++){if(_table.Schema.Name.Culture.CompareInfo.Compare(name,_table[i].Name,_table.Schema.Name.Options)==0){return i;}}throw new ArgumentException($"The column name, {name}, does not exist in {_table.IntoString()}.");}public DataTable GetSchemaTable(){DataTable schema=new(){MinimumCapacity=_table.ColumnCount,TableName=$"{_table.Schema.Name.Value}.{_table.Name}",Locale=_table.Schema.Name.Culture};_=schema.Columns.Add("Ordinal",typeof(ushort));_=schema.Columns.Add("ColumnName",typeof(string));_=schema.Columns.Add("DataType",typeof(Type));for(ushort i=0;i<_table.ColumnCount;i++){ref readonly var col=ref _table[i];_=schema.Rows.Add(i,col.Name,GetFieldType(i));}return schema;}public string GetString(int ordinal)=>(string)GetValue(ordinal);public object GetValue(int ordinal)=>ordinal switch{"#);
+ for j in 0..=i {
+ Kind::GetVal.write(s, j);
+ }
+ s.push_str("_=>throw new ArgumentOutOfRangeException(nameof(ordinal)),};public int GetValues(object[]values){var count=Math.Min(values.Length,_table.ColumnCount);for(var i=0;i<count;i++){values[i]=GetValue(i);}return count;}public bool IsDBNull(int ordinal)=>ordinal switch{");
+ for j in 0..=i {
+ Kind::IsNull.write(s, j);
+ }
+ s.push_str(r#"_=>throw new ArgumentOutOfRangeException(nameof(ordinal)),};public bool NextResult(){if(_errTableExists){_=WriteErrors(in _error,ref _errs,_processName,_userName,ushort.MinValue);}(_errs,_current,_iter,_ser)=(new Vec<Prod<nvarchar,nvarchar,varbinary>>(),default!,default!,default);return false;}public bool Read(){while(true){if(CurrentErrorCount>_maxErrorsAllowed.Item0&&CurrentErrorRatio>_maxErrorsAllowed.Item1){if(_errTableExists){_=WriteErrors(in _error,ref _errs,_processName,_userName,ushort.MinValue);}(_errs,_current,_iter,_ser)=(new Vec<Prod<nvarchar,nvarchar,varbinary>>(),default!,default!,default);return false;}var cur=_iter!.Next();if(cur.IsNone){if(_errTableExists){_=WriteErrors(in _error,ref _errs,_processName,_userName,ushort.MinValue);}(_errs,_current,_iter,_ser)=(new Vec<Prod<nvarchar,nvarchar,varbinary>>(),default!,default!,default);return false;}CurrentProcessedCount++;var res=cur.Unwrap();if(res.Variant==Var2.V1){CurrentErrorCount++;if(_errTableExists){var err=res.Variant1;_=_errs.Push(new(err.Trace,err.Message,err.Data));_=WriteErrors(in _error,ref _errs,_processName,_userName,4095);}continue;}_current=res.Variant0;if(_errTableExists?TruncateOverflowCheckAndLog():TruncateOverflowCheck()){continue;}else{return true;}}}public sealed override string ToString()=>string.Empty;bool TruncateOverflowCheck(){"#);
+ for j in 0..=i {
+ Kind::Truncation.write(s, j);
+ }
+ s.push_str("return false;}bool TruncateOverflowCheckAndLog(){");
+ for j in 0..=i {
+ Kind::TruncationLog.write(s, j);
+ }
+ s.push_str("return false;}}\n");
+ f.write_all(s.as_bytes())?;
+ s.clear();
+ }
+ f.write_all(&[b'}'])?;
+ f.flush()
+}
+/// The source code for an `IterDataReader` has multiple areas dependent
+/// on the n-arity tuple that is written to the table. The code of which
+/// is different, so we model those differences here.
+enum Kind {
+ /// Represents the sequence of type parameters T0...Tn.
+ T,
+ /// Represents the type bounds for T0...Tn.
+ Bound,
+ /// Represents the portion of the source code based on T0...Tn
+ /// in the `GetValue` function.
+ GetVal,
+ /// Represents the portion of the source code based on T0...Tn
+ /// in the `IsDBNull` function.
+ IsNull,
+ /// Represents the portion of the source code based on T0...Tn
+ /// in the `TruncateOverflowCheck` function.
+ Truncation,
+ /// Represents the portion of the source code based on T0...Tn
+ /// in the `TruncateOverflowCheckAndLog` function.
+ TruncationLog,
+}
+impl Kind {
+ /// Writes the source code related to a single type parameter.
+ fn write(self, buffer: &mut String, i: u8) {
+ let s = &i.to_string();
+ match self {
+ Self::T => {
+ buffer.push('T');
+ buffer.push_str(s);
+ buffer.push(',');
+ }
+ Self::Bound => {
+ buffer.push_str("where ");
+ buffer.push('T');
+ buffer.push_str(s);
+ buffer.push_str(":struct,IDataType ");
+ }
+ Self::GetVal => {
+ buffer.push_str(s);
+ buffer.push_str("=>_current.Field");
+ buffer.push_str(s);
+ buffer.push_str(".Val,");
+ }
+ Self::IsNull => {
+ buffer.push_str(s);
+ buffer.push_str("=>_current.Field");
+ buffer.push_str(s);
+ buffer.push_str(".IsNULL,");
+ }
+ Self::Truncation => {
+ buffer.push_str("if(_current.Field");
+ buffer.push_str(s);
+ buffer.push_str(".IsNULL){if(!_table[");
+ buffer.push_str(s);
+ buffer.push_str(
+ "].IsNullable){CurrentErrorCount++;return true;}}else if(_current.Field",
+ );
+ buffer.push_str(s);
+ buffer.push_str(".TruncationWillOccur(_table[");
+ buffer.push_str(s);
+ buffer.push_str("],_numericRoundAbort)){CurrentErrorCount++;return true;}");
+ }
+ Self::TruncationLog => {
+ buffer.push_str("if(_current.Field");
+ buffer.push_str(s);
+ buffer.push_str(".IsNULL){if(!_table[");
+ buffer.push_str(s);
+ buffer.push_str(
+ r#"].IsNullable){CurrentErrorCount++;_=_current.Ser(ref _ser);_=_errs.Push(new(_truncationStackTrace,new($"NULLs are not allowed in {_table.IntoString()}.{_table["#
+ );
+ buffer.push_str(s);
+ buffer.push_str(r#"].Name}."),varbinary.New(_ser.SerializedData)));_=WriteErrors(in _error,ref _errs,_processName,_userName,4095);_=_ser.Reset();return true;}}else if(_current.Field"#);
+ buffer.push_str(s);
+ buffer.push_str(".TruncationWillOccur(_table[");
+ buffer.push_str(s);
+ buffer.push_str(r#"],_numericRoundAbort)){CurrentErrorCount++;_=_current.Ser(ref _ser);_=_errs.Push(new(_truncationStackTrace,new($"{_current.Field"#);
+ buffer.push_str(s);
+ buffer.push_str(
+ ".Into()} would truncate or overflow in {_table.IntoString()}.{_table[",
+ );
+ buffer.push_str(s);
+ buffer.push_str(r#"].Name}."),varbinary.New(_ser.SerializedData)));_=WriteErrors(in _error,ref _errs,_processName,_userName,4095);_=_ser.Reset();return true;}"#);
+ }
+ }
+ }
+}
+/// The errors possible.
+enum GenErr {
+ /// Error when `$HOME` is not set.
+ HomeVarNotSet,
+ /// Error containing a general IO error.
+ Error(Error),
+}
+impl Display for GenErr {
+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
+ match *self {
+ Self::HomeVarNotSet => f.write_str("$HOME is not set."),
+ Self::Error(ref e) => <Error as Display>::fmt(e, f),
+ }
+ }
+}
+impl Debug for GenErr {
+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
+ <Self as Display>::fmt(self, f)
+ }
+}
+impl From<Error> for GenErr {
+ fn from(value: Error) -> Self {
+ Self::Error(value)
+ }
+}