Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
duniter-gva
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
modules
duniter-gva
Merge requests
!2
feat(gql): add query wallets
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
feat(gql): add query wallets
wallets
into
master
Overview
0
Commits
1
Pipelines
2
Changes
12
Merged
Éloïs
requested to merge
wallets
into
master
4 years ago
Overview
0
Commits
1
Pipelines
2
Changes
12
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
2f73e4bc
1 commit,
4 years ago
12 files
+
705
−
11
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
12
dbs-reader/src/cursors.rs
0 → 100644
+
83
−
0
View file @ 2f73e4bc
Edit in single-file editor
Open in Web IDE
// Copyright (C) 2020 Éloïs SANCHEZ.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use
crate
::
*
;
use
duniter_core
::
crypto
::
keys
::
ed25519
::
PublicKey
;
use
duniter_core
::
crypto
::
keys
::
PublicKey
as
_
;
use
duniter_core
::
dbs
::
WalletConditionsV2
;
#[derive(Clone,
Copy,
Debug)]
pub
struct
WrongCursor
;
impl
std
::
fmt
::
Display
for
WrongCursor
{
fn
fmt
(
&
self
,
f
:
&
mut
std
::
fmt
::
Formatter
<
'_
>
)
->
std
::
fmt
::
Result
{
write!
(
f
,
"wrong cursor"
)
}
}
impl
std
::
error
::
Error
for
WrongCursor
{}
pub
trait
Cursor
:
'static
+
Clone
+
std
::
fmt
::
Debug
+
std
::
fmt
::
Display
+
Default
+
FromStr
+
Ord
{
}
#[derive(Clone,
Copy,
Debug,
Default,
Eq,
PartialEq)]
pub
struct
PubKeyCursor
(
pub
PublicKey
);
impl
PubKeyCursor
{
pub
fn
from_ref
(
pk
:
&
PublicKey
)
->
&
Self
{
#[allow(trivial_casts)]
unsafe
{
&*
(
pk
as
*
const
PublicKey
as
*
const
PubKeyCursor
)
}
}
}
impl
Cursor
for
PubKeyCursor
{}
impl
std
::
fmt
::
Display
for
PubKeyCursor
{
fn
fmt
(
&
self
,
f
:
&
mut
std
::
fmt
::
Formatter
<
'_
>
)
->
std
::
fmt
::
Result
{
write!
(
f
,
"{}"
,
self
.0
.to_string
())
}
}
impl
FromStr
for
PubKeyCursor
{
type
Err
=
WrongCursor
;
fn
from_str
(
s
:
&
str
)
->
Result
<
Self
,
Self
::
Err
>
{
if
let
Ok
(
pk
)
=
PublicKey
::
from_base58
(
s
)
{
Ok
(
PubKeyCursor
(
pk
))
}
else
{
Err
(
WrongCursor
)
}
}
}
impl
From
<
PubKeyCursor
>
for
WalletConditionsV2
{
fn
from
(
val
:
PubKeyCursor
)
->
Self
{
WalletConditionsV2
(
WalletScriptV10
::
single_sig
(
val
.0
))
}
}
impl
Ord
for
PubKeyCursor
{
fn
cmp
(
&
self
,
other
:
&
Self
)
->
std
::
cmp
::
Ordering
{
self
.0
.as_ref
()
.cmp
(
other
.0
.as_ref
())
}
}
impl
PartialOrd
for
PubKeyCursor
{
fn
partial_cmp
(
&
self
,
other
:
&
Self
)
->
Option
<
std
::
cmp
::
Ordering
>
{
self
.0
.as_ref
()
.partial_cmp
(
other
.0
.as_ref
())
}
}
Loading