Skip to content

Commit 7386a07

Browse files
committed
change Into -> From in nexus external API views file
1 parent 3767f83 commit 7386a07

File tree

1 file changed

+38
-41
lines changed

1 file changed

+38
-41
lines changed

nexus/src/external_api/views.rs

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ pub struct Organization {
2626
pub identity: IdentityMetadata,
2727
}
2828

29-
impl Into<Organization> for model::Organization {
30-
fn into(self) -> Organization {
31-
Organization { identity: self.identity() }
29+
impl From<model::Organization> for Organization {
30+
fn from(o: model::Organization) -> Self {
31+
Self { identity: o.identity() }
3232
}
3333
}
3434

@@ -44,12 +44,9 @@ pub struct Project {
4444
pub organization_id: Uuid,
4545
}
4646

47-
impl Into<Project> for model::Project {
48-
fn into(self) -> Project {
49-
Project {
50-
identity: self.identity(),
51-
organization_id: self.organization_id,
52-
}
47+
impl From<model::Project> for Project {
48+
fn from(p: model::Project) -> Self {
49+
Self { identity: p.identity(), organization_id: p.organization_id }
5350
}
5451
}
5552

@@ -88,14 +85,14 @@ pub struct Vpc {
8885
pub dns_name: Name,
8986
}
9087

91-
impl Into<Vpc> for model::Vpc {
92-
fn into(self) -> Vpc {
93-
Vpc {
94-
identity: self.identity(),
95-
project_id: self.project_id,
96-
system_router_id: self.system_router_id,
97-
ipv6_prefix: *self.ipv6_prefix,
98-
dns_name: self.dns_name.0,
88+
impl From<model::Vpc> for Vpc {
89+
fn from(v: model::Vpc) -> Self {
90+
Self {
91+
identity: v.identity(),
92+
project_id: v.project_id,
93+
system_router_id: v.system_router_id,
94+
ipv6_prefix: *v.ipv6_prefix,
95+
dns_name: v.dns_name.0,
9996
}
10097
}
10198
}
@@ -118,13 +115,13 @@ pub struct VpcSubnet {
118115
pub ipv6_block: Ipv6Net,
119116
}
120117

121-
impl Into<VpcSubnet> for model::VpcSubnet {
122-
fn into(self) -> VpcSubnet {
123-
VpcSubnet {
124-
identity: self.identity(),
125-
vpc_id: self.vpc_id,
126-
ipv4_block: self.ipv4_block.0,
127-
ipv6_block: self.ipv6_block.0,
118+
impl From<model::VpcSubnet> for VpcSubnet {
119+
fn from(s: model::VpcSubnet) -> Self {
120+
Self {
121+
identity: s.identity(),
122+
vpc_id: s.vpc_id,
123+
ipv4_block: s.ipv4_block.0,
124+
ipv6_block: s.ipv6_block.0,
128125
}
129126
}
130127
}
@@ -174,9 +171,9 @@ pub struct Rack {
174171
pub identity: IdentityMetadata,
175172
}
176173

177-
impl Into<Rack> for model::Rack {
178-
fn into(self) -> Rack {
179-
Rack { identity: self.identity() }
174+
impl From<model::Rack> for Rack {
175+
fn from(r: model::Rack) -> Self {
176+
Self { identity: r.identity() }
180177
}
181178
}
182179

@@ -190,9 +187,9 @@ pub struct Sled {
190187
pub service_address: SocketAddr,
191188
}
192189

193-
impl Into<Sled> for model::Sled {
194-
fn into(self) -> Sled {
195-
Sled { identity: self.identity(), service_address: self.address() }
190+
impl From<model::Sled> for Sled {
191+
fn from(s: model::Sled) -> Self {
192+
Self { identity: s.identity(), service_address: s.address() }
196193
}
197194
}
198195

@@ -207,9 +204,9 @@ pub struct User {
207204
pub identity: IdentityMetadata,
208205
}
209206

210-
impl Into<User> for model::UserBuiltin {
211-
fn into(self) -> User {
212-
User { identity: self.identity() }
207+
impl From<model::UserBuiltin> for User {
208+
fn from(u: model::UserBuiltin) -> Self {
209+
Self { identity: u.identity() }
213210
}
214211
}
215212

@@ -221,9 +218,9 @@ pub struct SessionUser {
221218
pub id: Uuid,
222219
}
223220

224-
impl Into<SessionUser> for authn::Actor {
225-
fn into(self) -> SessionUser {
226-
SessionUser { id: self.0 }
221+
impl From<authn::Actor> for SessionUser {
222+
fn from(a: authn::Actor) -> Self {
223+
Self { id: a.0 }
227224
}
228225
}
229226

@@ -236,11 +233,11 @@ pub struct Role {
236233
pub description: String,
237234
}
238235

239-
impl Into<Role> for model::RoleBuiltin {
240-
fn into(self) -> Role {
241-
Role {
242-
name: RoleName::new(&self.resource_type, &self.role_name),
243-
description: self.description,
236+
impl From<model::RoleBuiltin> for Role {
237+
fn from(r: model::RoleBuiltin) -> Self {
238+
Self {
239+
name: RoleName::new(&r.resource_type, &r.role_name),
240+
description: r.description,
244241
}
245242
}
246243
}

0 commit comments

Comments
 (0)