@codama/renderers-rust 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,93 +1,33 @@
1
1
  {% extends "layout.njk" %}
2
2
  {% block main %}
3
3
 
4
- use std::fmt::Debug;
5
- use std::io::Write;
6
- use std::ops::{Deref, DerefMut};
7
-
8
- use borsh::maybestd::io::Read;
9
- use borsh::{BorshDeserialize, BorshSerialize};
10
-
11
- /// A vector that deserializes from a stream of bytes.
12
- ///
13
- /// This is useful for deserializing a vector that does not have
14
- /// a length prefix. In order to determine how many elements to deserialize,
15
- /// the type of the elements must implement the trait `Sized`.
16
- pub struct RemainderVec<T: BorshSerialize + BorshDeserialize>(Vec<T>);
17
-
18
- /// Deferences the inner `Vec` type.
19
- impl<T> Deref for RemainderVec<T>
20
- where
21
- T: BorshSerialize + BorshDeserialize,
22
- {
23
- type Target = Vec<T>;
24
-
25
- fn deref(&self) -> &Self::Target {
26
- &self.0
27
- }
28
- }
29
-
30
- /// Deferences the inner `Vec` type as mutable.
31
- impl<T> DerefMut for RemainderVec<T>
32
- where
33
- T: BorshSerialize + BorshDeserialize,
34
- {
35
- fn deref_mut(&mut self) -> &mut Self::Target {
36
- &mut self.0
4
+ {#
5
+ The following types are used as responses for function that fetch accounts.
6
+ Ideally, these types live in a shared crate that can be used by the client but
7
+ at time of writing, there are some unresolved questions about how to do this.
8
+
9
+ For now, we just define them here. This the following caveat:
10
+ - These types are not compatible between different clients since the type
11
+ exists in each client individually.
12
+ #}
13
+
14
+ {% if accountsToExport.length > 0 %}
15
+
16
+ #[cfg(feature = "fetch")]
17
+ #[derive(Debug, Clone)]
18
+ pub struct DecodedAccount<T> {
19
+ pub address: solana_program::pubkey::Pubkey,
20
+ pub account: solana_sdk::account::Account,
21
+ pub data: T,
37
22
  }
38
- }
39
23
 
40
- /// `Debug` implementation for `RemainderVec`.
41
- ///
42
- /// This implementation simply forwards to the inner `Vec` type.
43
- impl<T> Debug for RemainderVec<T>
44
- where
45
- T: BorshSerialize + BorshDeserialize + Debug,
46
- {
47
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
48
- f.write_fmt(format_args!("{:?}", self.0))
24
+ #[cfg(feature = "fetch")]
25
+ #[derive(Debug, Clone)]
26
+ pub enum MaybeAccount<T> {
27
+ Exists(DecodedAccount<T>),
28
+ NotFound(solana_program::pubkey::Pubkey),
49
29
  }
50
- }
51
30
 
52
- impl<T> BorshDeserialize for RemainderVec<T>
53
- where
54
- T: BorshSerialize + BorshDeserialize,
55
- {
56
- fn deserialize_reader<R: Read>(reader: &mut R) -> borsh::maybestd::io::Result<Self> {
57
- let length = std::mem::size_of::<T>();
58
- // buffer to read the data
59
- let mut buffer = vec![0u8; length];
60
- // vec to store the items
61
- let mut items: Vec<T> = Vec::new();
31
+ {% endif %}
62
32
 
63
- loop {
64
- match reader.read(&mut buffer)? {
65
- 0 => break,
66
- n if n == length => items.push(T::deserialize(&mut buffer.as_slice())?),
67
- e => {
68
- return Err(borsh::maybestd::io::Error::new(
69
- borsh::maybestd::io::ErrorKind::InvalidData,
70
- format!("unexpected number of bytes (read {e}, expected {length})"),
71
- ))
72
- }
73
- }
74
- }
75
-
76
- Ok(Self(items))
77
- }
78
- }
79
-
80
- impl<T> BorshSerialize for RemainderVec<T>
81
- where
82
- T: BorshSerialize + BorshDeserialize,
83
- {
84
- fn serialize<W: Write>(&self, writer: &mut W) -> borsh::maybestd::io::Result<()> {
85
- // serialize each item without adding a prefix for the length
86
- for item in self.0.iter() {
87
- item.serialize(writer)?;
88
- }
89
-
90
- Ok(())
91
- }
92
- }
93
- {% endblock %}
33
+ {% endblock %}
@@ -1 +1 @@
1
- {"version":3,"file":"getRenderMapVisitor.d.ts","sourceRoot":"","sources":["../../src/getRenderMapVisitor.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAenD,OAAO,EAAkD,aAAa,EAAU,YAAY,EAAE,MAAM,SAAS,CAAC;AAE9G,MAAM,MAAM,mBAAmB,GAAG;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC/B,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,mBAAwB,0IA8PpE"}
1
+ {"version":3,"file":"getRenderMapVisitor.d.ts","sourceRoot":"","sources":["../../src/getRenderMapVisitor.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAenD,OAAO,EAAkD,aAAa,EAAU,YAAY,EAAE,MAAM,SAAS,CAAC;AAE9G,MAAM,MAAM,mBAAmB,GAAG;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC/B,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,mBAAwB,0IAiQpE"}
@@ -1 +1 @@
1
- {"version":3,"file":"getTypeManifestVisitor.d.ts","sourceRoot":"","sources":["../../src/getTypeManifestVisitor.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAgB,MAAM,SAAS,CAAC;AAEzF,MAAM,MAAM,YAAY,GAAG;IACvB,OAAO,EAAE,SAAS,CAAC;IACnB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,OAAO,EAAE;IAC5C,aAAa,EAAE,qBAAqB,CAAC;IACrC,iBAAiB,EAAE,yBAAyB,CAAC;IAC7C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,utBAgbA"}
1
+ {"version":3,"file":"getTypeManifestVisitor.d.ts","sourceRoot":"","sources":["../../src/getTypeManifestVisitor.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAgB,MAAM,SAAS,CAAC;AAEzF,MAAM,MAAM,YAAY,GAAG;IACvB,OAAO,EAAE,SAAS,CAAC;IACnB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,OAAO,EAAE;IAC5C,aAAa,EAAE,qBAAqB,CAAC;IACrC,iBAAiB,EAAE,yBAAyB,CAAC;IAC7C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,utBAmbA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codama/renderers-rust",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Renders Rust clients for your programs",
5
5
  "exports": {
6
6
  "types": "./dist/types/index.d.ts",
@@ -30,10 +30,10 @@
30
30
  "dependencies": {
31
31
  "@solana/codecs-strings": "rc",
32
32
  "nunjucks": "^3.2.4",
33
- "@codama/errors": "1.2.0",
34
- "@codama/nodes": "1.2.0",
35
- "@codama/renderers-core": "1.0.2",
36
- "@codama/visitors-core": "1.2.0"
33
+ "@codama/nodes": "1.2.1",
34
+ "@codama/visitors-core": "1.2.1",
35
+ "@codama/renderers-core": "1.0.3",
36
+ "@codama/errors": "1.2.1"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/nunjucks": "^3.2.6"